BrokerPosition
public BrokerPosition(BrokerAccount ba)Creates a BrokerPosition associated with the supplied BrokerAccount.
API documentation, members, signatures, and C# examples.
Find classes, members, and documentation.
The BrokerPosition class represents a Position held in a BrokerAccount. It contains the Position's symbol, type, quantity, basis price, current price, security type, Strategy association, and values used by WealthLab's Live Position and Portfolio Sync processing.
public BrokerPosition(BrokerAccount ba)Creates a BrokerPosition associated with the supplied BrokerAccount.
public double ProfitReturns the current profit or loss of the Position based on CurrentPrice, BasisPrice, Quantity, PositionType, and the security's point-value multiplier. For Long Positions, profit is based on CurrentPrice - BasisPrice. For Short Positions, it is based on BasisPrice - CurrentPrice.
public double ProfitPctReturns the current profit or loss as a percentage of BasisValue. Returns zero if Value is zero.
public double ValueReturns the current value of the Position. WealthLab calculates the value from Quantity and BasisPrice and then applies the Position's Profit. Options use a multiplier of 100.
public string BasisPriceDisplayReturns BasisPrice formatted using the appropriate number of decimal places for the Symbol and Broker.
public string CurrentPriceDisplayReturns CurrentPrice formatted using the appropriate number of decimal places for the Symbol and Broker.
public string EntryDateDisplayReturns EntryDate formatted as a short date string. Returns an empty string if EntryDate is null.
public string QuantityDisplayReturns Quantity formatted using the number of decimal places appropriate for the Symbol and Broker. If the Quantity itself contains more decimal places than the configured quantity precision, WealthLab preserves those additional decimal places.
public string StrategyDisplayReturns the associated Strategy's QualifiedName. Returns an empty string if Strategy is null.
public DateTime? EntryDateGets or sets the Position's entry date. WealthLab uses this property when maintaining Live Positions and Strategy Positions for Portfolio Sync.
public DateTime? ExitDateGets or sets the Position's exit date. WealthLab uses this property when maintaining Live Positions for Portfolio Sync.
public double? ExitPriceGets or sets the Position's exit price. A null ExitPrice indicates that the Position is still open.
public bool IsOpenReturns true when ExitPrice is null, indicating that the Position is still open.
public BrokerAccount AccountGets or sets the BrokerAccount associated with this Position.
public double BasisPriceGets or sets the Position's basis price, representing the price at which the shares or contracts were acquired.
public double BasisValueReturns the total basis value of the Position, calculated from BasisPrice, Quantity, and the security's point-value multiplier.
public int? CancelationCodeGets or sets an optional cancellation code associated with the Position. WealthLab uses this value when processing certain orphan Position exits.
public double CurrentAndBasisPriceReturns CurrentPrice when CurrentPrice is zero; otherwise returns BasisPrice. WealthLab uses this property for display and visibility purposes.
public double CurrentPriceGets or sets the most recent price of the Position's underlying Symbol as reported by the Broker. The default value is Double.NaN.
public PositionType PositionTypeGets or sets the Position type, typically PositionType.Long or PositionType.Short.
Possible values are:
public double QuantityGets or sets the number of shares, contracts, or other units held in the Position.
public SecurityType SecurityTypeGets or sets the security type represented by the Position. Possible values are:
public DateTime SignalDateGets or sets the Signal Date associated with the Position. WealthLab uses this value when processing certain orphan Position exits.
public Strategy Strategypublic string SymbolGets or sets the Position's symbol. When assigned, WealthLab determines applicable security information for the symbol. Option symbols are assigned a SecurityType of Option and a multiplier of 100. When SymbolInfo is available, the security's PointValue and SecurityType are used for Position calculations.
public BrokerPosition Clone()Creates and returns a copy of the BrokerPosition using its persisted representation. The cloned Position remains associated with the same BrokerAccount.
public static BrokerPosition Parse(string s, BrokerAccount ba)Creates and returns a BrokerPosition from the persisted string s, associating it with the BrokerAccount ba. The method restores the Position's Symbol, PositionType, Quantity, BasisPrice, CurrentPrice, EntryDate, and Strategy association when available.
public string Persist()Returns a persisted representation of the BrokerPosition. The persisted data includes Symbol, PositionType, Quantity, BasisPrice, CurrentPrice, EntryDate, and the associated Strategy's QualifiedName when a Strategy is assigned.
public string FormatPrice(double price)Returns price formatted using the appropriate number of decimal places for the Position's Symbol and Broker.
public override string ToString()Returns a string representation containing the PositionType, Quantity, Symbol, and SignalDate.
Ask the community or explore custom development services.