Parent: Object
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.
Creates a BrokerPosition associated with the supplied BrokerAccount.
Returns 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.
Returns the current profit or loss as a percentage of BasisValue. Returns zero if Value is zero.
Returns 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.
Returns BasisPrice formatted using the appropriate number of decimal places for the Symbol and Broker.
Returns CurrentPrice formatted using the appropriate number of decimal places for the Symbol and Broker.
Returns EntryDate formatted as a short date string. Returns an empty string if EntryDate is null.
Returns 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.
Returns the associated Strategy's QualifiedName. Returns an empty string if Strategy is null.
Gets or sets the Position's entry date. WealthLab uses this property when maintaining Live Positions and Strategy Positions for Portfolio Sync.
Gets or sets the Position's exit date. WealthLab uses this property when maintaining Live Positions for Portfolio Sync.
Gets or sets the Position's exit price. A null ExitPrice indicates that the Position is still open.
Returns true when ExitPrice is null, indicating that the Position is still open.
Gets or sets the Position's basis price, representing the price at which the shares or contracts were acquired.
Returns the total basis value of the Position, calculated from BasisPrice, Quantity, and the security's point-value multiplier.
Gets or sets an optional cancellation code associated with the Position. WealthLab uses this value when processing certain orphan Position exits.
Returns CurrentPrice when CurrentPrice is zero; otherwise returns BasisPrice. WealthLab uses this property for display and visibility purposes.
Gets or sets the most recent price of the Position's underlying Symbol as reported by the Broker. The default value is Double.NaN.
Gets or sets the Position type, typically PositionType.Long or PositionType.Short.
Possible values are:
- Long
- Short
Gets or sets the number of shares, contracts, or other units held in the Position.
Gets or sets the security type represented by the Position. Possible values are:
- Stock
- ETF
- Index
- Fund
- Future
- Option
- Forex
- Crypto
- Bond
- SSF
- CFD
- ContinuousFuture
- FuturesOption
- Unknown
- Combo
Gets or sets the Signal Date associated with the Position. WealthLab uses this value when processing certain orphan Position exits.
Gets 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.
Creates and returns a copy of the BrokerPosition using its persisted representation. The cloned Position remains associated with the same BrokerAccount.
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.
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.
Returns price formatted using the appropriate number of decimal places for the Position's Symbol and Broker.
Returns a string representation containing the PositionType, Quantity, Symbol, and SignalDate.