Parent: Object
The BrokerAccount class represents an account associated with a connected Broker Provider. It contains account balances, Broker-reported Positions, currency balances, Portfolio Sync Live Positions, Strategy Positions, and other account-specific information.
Represents the overall account balance or value. The default value is Double.NaN. If the Broker does not expose a value that maps cleanly to AccountValue, leave it unassigned and use CustomFields for Broker-specific information.
Represents the current buying power available in the account. The default value is Double.NaN. If the Broker does not expose a value that maps cleanly to BuyingPower, leave it unassigned and use CustomFields.
Represents the available cash balance in the account. The default value is Double.NaN. If the Broker does not expose a value that maps cleanly to Cash, leave it unassigned and use CustomFields.
Contains Broker-specific account values that do not map cleanly to the standard AccountValue, Cash, BuyingPower, or other BrokerAccount properties. WealthLab can display these values along with the standard account balances.
Represents the account's gain or loss for the current trading day. The default value is Double.NaN.
Returns all Broker-reported Positions matching the specified symbol and PositionType. This is useful for Brokers that maintain multiple separate lots for the same symbol and PositionType.
Returns a copy of the Broker-reported Positions. This method is obsolete. Use GetPositionsSnapshot instead.
Returns a stable snapshot of the current Broker-reported Positions. Use this method when code needs to enumerate or otherwise work with a consistent view of the Positions while the Broker Provider may be updating them concurrently.
Gets or sets the Broker-reported Positions currently held in the account. Broker Providers typically create a BrokerPosition for each open Position reported by the Broker and assign or add them to this collection. Access to the underlying collection is protected by a reader/writer lock. Code that needs a stable copy of the Positions should use GetPositionsSnapshot.
Returns the total current profit of all Broker-reported Positions by summing each BrokerPosition's Profit.
Returns the total percentage profit of the Broker-reported Positions. WealthLab calculates the total cost basis from each Position's Quantity * BasisPrice, and expresses PositionsProfit as a percentage of that total basis. Returns zero if the total basis is zero.
Returns the total current value of all Broker-reported Positions by summing each BrokerPosition's Value.
Creates a BrokerAccount associated with the supplied BrokerBase instance.
Contains account balances keyed by currency symbol. Broker Providers can populate this Dictionary for accounts that hold balances in multiple currencies.
Returns the balance associated with the specified currency symbol. Returns zero if the currency is not present in CurrencyBalances.
Sets the balance for the specified currency symbol. If value is zero, the currency is removed from CurrencyBalances.
Gets or sets the account number or identifier associated with this account.
Gets or sets the BrokerBase instance associated with the account.
Returns the account's display name. If a Nickname has been assigned, returns the nickname followed by the AccountID in parentheses. Otherwise returns the AccountID.
Returns the Broker and account identifier combined in the form: BrokerName:AccountID
Gets or sets a user-defined nickname for the account. WealthLab persists the nickname in the user's settings.
Returns the value of DisplayName.
Contains the account's Portfolio Sync Live Positions. These are generated and maintained by WealthLab when synchronizing the Broker's actual Positions with Strategy execution.
Returns the earliest EntryDate among the account's LivePositions. Returns null when no Live Positions are present.
Gets or sets an arbitrary object that a Broker Provider can associate with the account for Provider-specific purposes.
Creates and returns a copy of the BrokerAccount using its persisted representation. The cloned account remains associated with the same BrokerBase instance.
Creates and returns a BrokerAccount from the persisted string s, associating it with the BrokerBase instance bb. The method restores the account balances, Broker Positions, and CurrencyBalances, and loads the account's persisted Strategy Positions.
Returns a persisted representation of the BrokerAccount. The persisted data includes AccountID, AccountValue, Cash, BuyingPower, Broker-reported Positions, and CurrencyBalances.
Returns the Strategy Position matching the supplied Strategy, symbol, and PositionType. Strategy matching is based on the Strategy's QualifiedName.
If considerMatchFlag is true, only a Strategy Position whose MatchedInPortSync flag is currently false is returned. The returned Position is then marked as matched. This behavior is used during Portfolio Sync processing.
Returns the number of Strategy Positions associated with the supplied Strategy. Matching is based on the Strategy's QualifiedName. Returns zero if s is null.
Updates the account's Strategy Positions based on a filled Transaction. For an entry Transaction, WealthLab creates or increases the matching Strategy Position. For an exit Transaction, it reduces the matching Strategy Position and removes it when its Quantity reaches zero. Updated Strategy Positions are persisted to the local trade history.
Returns WealthLab's internal collection of Positions created from Strategy fills for this account. Strategy Positions are separate from the Broker-reported Positions collection and are used by Portfolio Sync features such as the trading preference that restricts Strategies to exiting only linked Positions.
Gets or sets the TradingThresholds associated with this Broker account. WealthLab persists Trading Threshold settings separately for each Broker and AccountID. When first accessed, the property loads previously saved thresholds or creates a new TradingThresholds instance if none have been saved.