NautilusTrader
ConceptsEvents
These docs track the unreleased nightly build and may change without notice. Switch to the latest stable docs.

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). Handler: on_position_opened.

Fields

See Position event fields for the complete field matrix. PositionOpened contains the opening snapshot; later events expose additional aggregate and lifecycle fields. At opening, realized PnL subtracts the opening fill's commission when that commission is denominated in the instrument's cost currency. Otherwise, it is zero. A reopened NETTING position starts a new cycle; realized PnL from the prior cycle remains in the closed position snapshot.

Its main state fields are:

FieldPython typeDescription
entryOrderSideThe entry order side that opened the position.
sidePositionSideThe current position side (LONG or SHORT).
signed_qtyfloatThe signed position quantity.
quantityQuantityThe current open quantity.
last_qtyQuantityThe quantity of the fill that opened the position.
last_pxPriceThe price of the fill that opened the position.
currencyCurrencyThe position quote currency.
avg_px_openfloatThe average open price.
realized_pnlMoney or NoneThe current cycle's realized PnL in cost currency.

Example

Reading the event in a strategy handler:

def on_position_opened(self, event: PositionOpened) -> None:
    self.log.info(
        f"Opened {event.side} {event.quantity} {event.instrument_id} @ {event.avg_px_open}",
    )
  • Events - Event categories, dispatch, and the fill‑to‑position chain.
  • Positions - Position lifecycle, aggregation, and PnL.
  • Orders - Orders whose fills open and close positions.

On this page