Expand description
A cash account that cannot hold leveraged positions.
§Balance locking
The account tracks locked balances per (InstrumentId, Currency) to support
instruments that lock different currencies depending on order side:
- BUY orders lock quote currency (cost of purchase).
- SELL orders lock base currency (assets being sold).
Instruments that model no base currency (binary options, equities, and the other types whose
base_currency() is None) have no asset to reserve, so a SELL locks nothing rather than
labeling the quantity as quote money. Inventory availability for those instruments is not
tracked or checked locally, including across concurrent SELLs, and is left to the venue,
whose rejections arrive through the normal order lifecycle.
Callers must clear all existing locks via CashAccount::clear_balance_locked
before applying new locks. This prevents stale currency entries when order
compositions change.
§Graceful degradation
When total locked exceeds total balance (e.g., due to venue/client state latency), the account clamps locked to total rather than raising an error. This yields zero free balance, preventing new orders while avoiding crashes in live trading.
Structs§
- Cash
Account - Represents a cash account that cannot hold leveraged positions.