docs/concepts/events/position_changed.md
PositionChanged represents a position having changed. The ExecutionEngine emits it
when a subsequent fill changes an open position's quantity or side (see From fill to position). Handler:
on_position_changed.
PositionChanged shares the position event field set. See Position event fields for the full matrix across
the three events. The fields that distinguish PositionChanged:
| Field | Python type | Description |
|---|---|---|
peak_qty | Quantity | The peak directional quantity reached by the position. |
avg_px_close | float | The average close price so far. |
realized_return | float | The realized return for the position. |
realized_pnl | Money | The realized PnL for the position. |
unrealized_pnl | Money | The unrealized PnL for the position. |
While the position remains open, closing_order_id is still None.
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})",
)