@@ -41,30 +41,30 @@ omit the callback, the event is delivered to `on_event` instead.
4141## Order events
4242
4343Each order event corresponds to a state transition in the
44- [ order state machine] ( orders/index.md#order-state-flow ) . The ` ExecutionEngine `
44+ [ order state machine] ( ../ orders/index.md#order-state-flow) . The ` ExecutionEngine `
4545applies the event to the order, updates the ` Cache ` , and publishes it on the
4646` MessageBus ` . The table below shows the primary transitions; partially filled
4747and triggered orders support additional transitions documented in the full
48- [ order state flow] ( orders/index.md#order-state-flow ) .
49-
50- | Event | Primary transition | Handler |
51- | ------------------------| - ------------------------------------| ----------------------------|
52- | ` OrderInitialized ` | (created locally) | ` on_order_initialized ` |
53- | ` OrderDenied ` | Initialized -> Denied | ` on_order_denied ` |
54- | ` OrderEmulated ` | Initialized -> Emulated | ` on_order_emulated ` |
55- | ` OrderReleased ` | Emulated -> Released | ` on_order_released ` |
56- | ` OrderSubmitted ` | Initialized/Released -> Submitted | ` on_order_submitted ` |
57- | ` OrderAccepted ` | Submitted -> Accepted | ` on_order_accepted ` |
58- | ` OrderRejected ` | Submitted -> Rejected | ` on_order_rejected ` |
59- | ` OrderTriggered ` | Accepted -> Triggered | ` on_order_triggered ` |
60- | ` OrderPendingUpdate ` | Accepted -> PendingUpdate | ` on_order_pending_update ` |
61- | ` OrderPendingCancel ` | Accepted -> PendingCancel | ` on_order_pending_cancel ` |
62- | ` OrderUpdated ` | PendingUpdate -> Accepted | ` on_order_updated ` |
63- | ` OrderModifyRejected ` | PendingUpdate -> Accepted | ` on_order_modify_rejected ` |
64- | ` OrderCancelRejected ` | PendingCancel -> Accepted | ` on_order_cancel_rejected ` |
65- | ` OrderCanceled ` | PendingCancel/Accepted -> Canceled | ` on_order_canceled ` |
66- | ` OrderExpired ` | Accepted -> Expired | ` on_order_expired ` |
67- | ` OrderFilled ` | Accepted -> Filled/PartiallyFilled | ` on_order_filled ` |
48+ [ order state flow] ( ../ orders/index.md#order-state-flow) .
49+
50+ | Event | Primary transition | Handler |
51+ | --------------------------------------------------- | ------------------------------------| ----------------------------|
52+ | [ ` OrderInitialized ` ] ( order_initialized.md ) | (created locally) | ` on_order_initialized ` |
53+ | [ ` OrderDenied ` ] ( order_denied.md ) | Initialized -> Denied | ` on_order_denied ` |
54+ | [ ` OrderEmulated ` ] ( order_emulated.md ) | Initialized -> Emulated | ` on_order_emulated ` |
55+ | [ ` OrderReleased ` ] ( order_released.md ) | Emulated -> Released | ` on_order_released ` |
56+ | [ ` OrderSubmitted ` ] ( order_submitted.md ) | Initialized/Released -> Submitted | ` on_order_submitted ` |
57+ | [ ` OrderAccepted ` ] ( order_accepted.md ) | Submitted -> Accepted | ` on_order_accepted ` |
58+ | [ ` OrderRejected ` ] ( order_rejected.md ) | Submitted -> Rejected | ` on_order_rejected ` |
59+ | [ ` OrderTriggered ` ] ( order_triggered.md ) | Accepted -> Triggered | ` on_order_triggered ` |
60+ | [ ` OrderPendingUpdate ` ] ( order_pending_update.md ) | Accepted -> PendingUpdate | ` on_order_pending_update ` |
61+ | [ ` OrderPendingCancel ` ] ( order_pending_cancel.md ) | Accepted -> PendingCancel | ` on_order_pending_cancel ` |
62+ | [ ` OrderUpdated ` ] ( order_updated.md ) | PendingUpdate -> previous status | ` on_order_updated ` |
63+ | [ ` OrderModifyRejected ` ] ( order_modify_rejected.md ) | PendingUpdate -> previous status | ` on_order_modify_rejected ` |
64+ | [ ` OrderCancelRejected ` ] ( order_cancel_rejected.md ) | PendingCancel -> previous status | ` on_order_cancel_rejected ` |
65+ | [ ` OrderCanceled ` ] ( order_canceled.md ) | PendingCancel/Accepted -> Canceled | ` on_order_canceled ` |
66+ | [ ` OrderExpired ` ] ( order_expired.md ) | Accepted -> Expired | ` on_order_expired ` |
67+ | [ ` OrderFilled ` ] ( order_filled.md ) | Accepted -> Filled/PartiallyFilled | ` on_order_filled ` |
6868
6969### Common order event fields
7070
@@ -83,13 +83,14 @@ All order events share these fields:
8383| ` ts_event ` | Timestamp when the event occurred. |
8484| ` ts_init ` | Timestamp when the event was created. |
8585
86- Individual events add type-specific fields (e.g. ` OrderFilled ` adds
87- ` last_qty ` , ` last_px ` , ` trade_id ` , ` commission ` ). See the API reference
88- for the full field list per event type.
86+ Each order event's page lists the type-specific fields it adds beyond this
87+ common set, plus which optional common fields are populated. For example,
88+ [ ` OrderFilled ` ] ( order_filled.md ) adds ` last_qty ` , ` last_px ` , ` trade_id ` , and
89+ ` commission ` .
8990
9091::: tip
9192Override ` on_order_event ` to handle all order events in one place. The specific
92- handlers fire first, so you can mix both approaches.
93+ handlers fire first, so you can combine both approaches.
9394:::
9495
9596## Position events
@@ -98,11 +99,11 @@ Position events are a direct consequence of fill events. The `ExecutionEngine`
9899processes each ` OrderFilled ` , updates or creates a position, and emits the
99100corresponding position event.
100101
101- | Event | When it fires | Handler |
102- | ---------------------| -------------------------------------------| -----------------------|
103- | ` PositionOpened ` | First fill creates a new position. | ` on_position_opened ` |
104- | ` PositionChanged ` | Subsequent fill changes quantity or side. | ` on_position_changed ` |
105- | ` PositionClosed ` | Fill reduces quantity to zero. | ` on_position_closed ` |
102+ | Event | When it fires | Handler |
103+ | ------------------------------------------ | -------------------------------------------| -----------------------|
104+ | [ ` PositionOpened ` ] ( position_opened.md ) | First fill creates a new position. | ` on_position_opened ` |
105+ | [ ` PositionChanged ` ] ( position_changed.md ) | Subsequent fill changes quantity or side. | ` on_position_changed ` |
106+ | [ ` PositionClosed ` ] ( position_closed.md ) | Fill reduces quantity to zero. | ` on_position_closed ` |
106107
107108### From fill to position: the causal chain
108109
@@ -157,6 +158,11 @@ sequenceDiagram
157158
158159### Position event fields
159160
161+ Every position event exposes all of these fields (they are defined on the ` PositionEvent `
162+ base). A check mark means the field carries a meaningful value for that event; a dash means
163+ it is left at its zero or default (for example ` avg_px_close ` and ` duration_ns ` before a
164+ position closes).
165+
160166| Field | Opened | Changed | Closed | Description |
161167| ----------------------| --------| ---------| --------| -----------------------------------|
162168| ` trader_id ` | ✓ | ✓ | ✓ | Trader instance identifier. |
@@ -170,17 +176,17 @@ sequenceDiagram
170176| ` side ` | ✓ | ✓ | ✓ | Current position side. |
171177| ` signed_qty ` | ✓ | ✓ | ✓ | Signed quantity (negative=short). |
172178| ` quantity ` | ✓ | ✓ | ✓ | Unsigned position quantity. |
173- | ` peak_qty ` | - | ✓ | ✓ | Largest quantity held. |
179+ | ` peak_qty ` | ✓ | ✓ | ✓ | Largest quantity held. |
174180| ` last_qty ` | ✓ | ✓ | ✓ | Quantity of the last fill. |
175181| ` last_px ` | ✓ | ✓ | ✓ | Price of the last fill. |
176182| ` currency ` | ✓ | ✓ | ✓ | Settlement currency. |
177183| ` avg_px_open ` | ✓ | ✓ | ✓ | Average entry price. |
178184| ` avg_px_close ` | - | ✓ | ✓ | Average exit price. |
179185| ` realized_return ` | - | ✓ | ✓ | Realized return as a ratio. |
180- | ` realized_pnl ` | - | ✓ | ✓ | Realized profit and loss. |
186+ | ` realized_pnl ` | ✓ | ✓ | ✓ | Realized profit and loss. |
181187| ` unrealized_pnl ` | - | ✓ | ✓ | Unrealized profit and loss. |
182188| ` duration_ns ` | - | - | ✓ | Time held in nanoseconds. |
183- | ` ts_opened ` | - | ✓ | ✓ | Timestamp when position opened. |
189+ | ` ts_opened ` | ✓ | ✓ | ✓ | Timestamp when position opened. |
184190| ` ts_closed ` | - | - | ✓ | Timestamp when position closed. |
185191| ` event_id ` | ✓ | ✓ | ✓ | Unique event identifier. |
186192| ` ts_event ` | ✓ | ✓ | ✓ | Timestamp of the triggering fill. |
@@ -211,7 +217,8 @@ opening_order_id = position.opening_order_id
211217
212218Account state contains balances, margins, account type, and base currency.
213219The ` Portfolio ` subscribes to these events internally to maintain exposure
214- and balance tracking.
220+ and balance tracking. See [ ` AccountState ` ] ( account_state.md ) for the full
221+ field list.
215222
216223## Event subscriptions
217224
@@ -230,12 +237,12 @@ These are useful for monitoring actors that track execution quality or fill
230237rates across strategies without participating in order management.
231238
232239For details and examples, see
233- [ Order event subscriptions] ( actors.md#order-event-subscriptions ) .
240+ [ Order event subscriptions] ( ../ actors.md#order-event-subscriptions) .
234241
235242## Related guides
236243
237- - [ Orders] ( orders/ ) - Order types and state machine.
238- - [ Positions] ( positions.md ) - Position lifecycle and PnL.
239- - [ Execution] ( execution.md ) - Execution flow and risk checks.
240- - [ Strategies] ( strategies.md ) - Handler implementations in strategies.
241- - [ Architecture] ( architecture.md ) - Data and execution flow patterns.
244+ - [ Orders] ( ../ orders/) - Order types and state machine.
245+ - [ Positions] ( ../ positions.md) - Position lifecycle and PnL.
246+ - [ Execution] ( ../ execution.md) - Execution flow and risk checks.
247+ - [ Strategies] ( ../ strategies.md) - Handler implementations in strategies.
248+ - [ Architecture] ( ../ architecture.md) - Data and execution flow patterns.
0 commit comments