PositionChanged
PositionChanged records an update that leaves a position open. The ExecutionEngine emits it when
a fill changes an open position without closing it, or when a fill correction leaves the corrected
position open. See From fill to position.
Handler: on_position_changed.
Fields
See Position event fields for the complete field matrix. In addition
to the opening snapshot fields, PositionChanged exposes:
| Field | Python type | Description |
|---|---|---|
peak_quantity | Quantity | The largest directional quantity reached by the position. |
peak_qty | Quantity | Compatibility alias for peak_quantity. |
avg_px_close | float or None | The average close price so far, if any quantity has closed. |
realized_return | float | The realized return for the position. |
realized_pnl | Money or None | The realized PnL, if available. |
unrealized_pnl | Money | Set to zero by the engine, not a mark‑to‑market calculation. |
ts_opened | int | UNIX timestamp (nanoseconds) when the position opened. |
Example
Reading the event in a strategy handler:
def on_position_changed(self, event: PositionChanged) -> None:
self.log.info(
f"Changed {event.instrument_id} to {event.signed_qty} (realized={event.realized_pnl})",
)Related guides
PositionOpened
PositionOpened records the opening snapshot of a new position. The ExecutionEngine emits it when a fill creates the position (see From fill to position)....
PositionClosed
PositionClosed records the final snapshot of a position. The ExecutionEngine emits it when a fill flattens the position or a fill correction leaves the...