What Trading State Is
praxis/core/trading_state.py is the per-account projection of orders, positions, and terminal history. It is not an independent store. It is a derived view rebuilt by applying events in sequence.
Each account runtime owns one TradingState.
What It Tracks
The current projection maintains:
positions: keyed by(trade_id, account_id)orders: active orders keyed byclient_order_idclosed_orders: terminal orders moved out of active trackingtrade_strategy_ids: strategy attribution keyed bytrade_id
How It Evolves
The projection is updated through TradingState.apply(event).
Important behaviors:
OrderSubmitIntentcreates an order inSUBMITTINGOrderSubmittedattaches venue order id and moves the order toOPENFillReceivedupdates both the order and the position- terminal order events move orders into
closed_orders
Position Semantics
Positions are keyed by trade rather than by symbol netting alone. That means Praxis can preserve trade-level attribution and strategy ownership.
Current fill behavior:
- same-side fills increase position quantity and recompute weighted average entry
- opposite-side fills reduce position quantity
- position quantity is clamped at zero if a reduction would otherwise go negative
Relation To Reconciliation
TradingState is the local view used during reconciliation. Praxis compares the projected local state with venue state and backfills missing fills or terminal statuses when needed.
Current Boundary
The RFC describes a broader world with an Account sub-system and richer accounting projections. The current TradingState is narrower: it is an execution-state projection for orders and positions, not a full accounting ledger.