Reading Position Opening Events and Their PnL Fields
Summary
This document explains the event emitted when a fill establishes a position and the opening state it makes available to a strategy handler. The event captures the entry order side, current position direction, signed and open quantities, details of the opening fill, quote currency, average entry price, and realized profit or loss for the current cycle.
The PnL treatment depends on commission currency: an opening commission reduces realized PnL when charged in the instrument’s cost currency; otherwise, the opening event reports zero realized PnL. If a position is reopened under netting, the new cycle begins separately, while the previous cycle’s realized result is retained in its closed-position record. These details help handlers interpret position state and avoid mixing results across cycles. The document describes event fields and lifecycle behavior, but provides no trading rules, performance evidence, or guidance on handling commissions in other currencies.
Key ideas
- A fill that creates a position triggers an event containing an opening snapshot.
- The snapshot distinguishes the position’s current open quantity from the quantity of the fill that established it.
- Realized PnL at opening reflects commission only when that charge uses the instrument’s cost currency.
- Reopening a netted position starts a separate cycle, with the earlier cycle’s result kept in its closed record.
Tags
Full text
# PositionOpened
# 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](index.md#from-fill-to-position-the-causal-chain)). Handler:
`on_position_opened`.
## Fields
See [Position event fields](index.md#position-event-fields) for the complete field matrix. `PositionOpened`
contains the opening snapshot. Later events expose additional aggregate and lifecycle fields. Its main state
fields are:
| Field | Python type | Description |
| -------------- | ----------------- | -------------------------------------------------- |
| `entry` | `OrderSide` | The entry order side that opened the position. |
| `side` | `PositionSide` | The current position side (`LONG` or `SHORT`). |
| `signed_qty` | `float` | The signed position quantity. |
| `quantity` | `Quantity` | The current open quantity. |
| `last_qty` | `Quantity` | The quantity of the fill that opened the position. |
| `last_px` | `Price` | The price of the fill that opened the position. |
| `currency` | `Currency` | The position quote currency. |
| `avg_px_open` | `float` | The average open price. |
| `realized_pnl` | `Money` or `None` | The current cycle's realized PnL in cost currency. |
At opening, realized PnL subtracts the opening fill's commission when that commission is denominated
in the instrument's [cost currency](../positions.md#currency-considerations). Otherwise, it is zero.
A reopened `NETTING` position starts a new cycle. Realized PnL from the prior cycle stays in the
[closed position snapshot](../positions.md#position-snapshotting).
## Example
Reading the event in a strategy handler:
```python
def on_position_opened(self, event: PositionOpened) -> None:
self.log.info(
f"Opened {event.side} {event.quantity} {event.instrument_id} @ {event.avg_px_open}",
)
```
## Related guides
- [Events](index.md) - Event categories, dispatch, and the fill-to-position chain.
- [Positions](../positions.md) - Position lifecycle, aggregation, and PnL.
- [Orders](../orders/) - Orders whose fills open and close positions.Shown in full with attribution under the source's licence. Licence: LGPL-3.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.