Events

Defines the fundamental event types represented within the trading domain.

class AccountState

Bases: Event

AccountState(AccountId account_id, AccountType account_type, Currency base_currency, bool reported, list balances, list margins, dict info, UUID4 event_id, uint64_t ts_event, uint64_t ts_init)

Represents an event which includes information on the state of the account.

Parameters:
  • account_id (AccountId) – The account ID (with the venue).

  • account_type (AccountType) – The account type for the event.

  • base_currency (Currency, optional) – The account base currency. Use None for multi-currency accounts.

  • reported (bool) – If the state is reported from the exchange (otherwise system calculated).

  • balances (list[AccountBalance]) – The account balances.

  • margins (list[MarginBalance]) – The margin balances (can be empty).

  • info (dict [str, object]) – The additional implementation specific account information.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the account state event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Raises:

ValueError – If balances is empty.

account_id

The account ID associated with the event.

Returns:

AccountId

account_type

The account type for the event.

Returns:

AccountType

balances

The account balances.

Returns:

list[AccountBalance]

base_currency

The account type for the event.

Returns:

Currency or None

static from_dict(dict values) AccountState

Return an account state event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

AccountState

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

AccountState.id

info

The additional implementation specific account information.

Returns:

dict[str, object]

is_reported

If the state is reported from the exchange (otherwise system calculated).

Returns:

bool

margins

The margin balances.

Returns:

list[MarginBalance]

static to_dict(AccountState obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

AccountState.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

AccountState.ts_init

class OrderAccepted

Bases: OrderEvent

OrderAccepted(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id, AccountId account_id, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has been accepted by the trading venue.

This event often corresponds to a NEW OrdStatus <39> field in FIX execution reports.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).

  • account_id (AccountId) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order accepted event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderAccepted.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderAccepted.client_order_id

static from_dict(dict values) OrderAccepted

Return an order accepted event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderAccepted

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderAccepted.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderAccepted.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderAccepted.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderAccepted.strategy_id

static to_dict(OrderAccepted obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderAccepted.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderAccepted.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderAccepted.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderAccepted.venue_order_id

class OrderCancelRejected

Bases: OrderEvent

OrderCancelRejected(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, str reason, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where a CancelOrder command has been rejected by the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • reason (str) – The order cancel rejected reason.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order cancel rejected event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderCancelRejected.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderCancelRejected.client_order_id

static from_dict(dict values) OrderCancelRejected

Return an order cancel rejected event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderCancelRejected

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderCancelRejected.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderCancelRejected.instrument_id

reason

str

Return the reason the order was rejected.

Return type:

str

Type:

OrderCancelRejected.reason

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderCancelRejected.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderCancelRejected.strategy_id

static to_dict(OrderCancelRejected obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderCancelRejected.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderCancelRejected.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderCancelRejected.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderCancelRejected.venue_order_id

class OrderCanceled

Bases: OrderEvent

OrderCanceled(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has been canceled at the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when order canceled event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderCanceled.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderCanceled.client_order_id

static from_dict(dict values) OrderCanceled

Return an order canceled event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderCanceled

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderCanceled.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderCanceled.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderCanceled.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderCanceled.strategy_id

static to_dict(OrderCanceled obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderCanceled.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderCanceled.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderCanceled.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderCanceled.venue_order_id

class OrderDenied

Bases: OrderEvent

OrderDenied(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, str reason, UUID4 event_id, uint64_t ts_init)

Represents an event where an order has been denied by the Nautilus system.

This could be due an unsupported feature, a risk limit exceedance, or for any other reason that an otherwise valid order is not able to be submitted.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • reason (str) – The order denied reason.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderDenied.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderDenied.client_order_id

static from_dict(dict values) OrderDenied

Return an order denied event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderDenied

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderDenied.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderDenied.instrument_id

reason

str

Return the reason the order was denied.

Return type:

str

Type:

OrderDenied.reason

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderDenied.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderDenied.strategy_id

static to_dict(OrderDenied obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderDenied.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderDenied.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderDenied.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderDenied.venue_order_id

class OrderEmulated

Bases: OrderEvent

OrderEmulated(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, UUID4 event_id, uint64_t ts_init)

Represents an event where an order has become emulated by the Nautilus system.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderEmulated.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderEmulated.client_order_id

static from_dict(dict values) OrderEmulated

Return an order emulated event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderEmulated

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderEmulated.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderEmulated.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderEmulated.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderEmulated.strategy_id

static to_dict(OrderEmulated obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderEmulated.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderEmulated.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderEmulated.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderEmulated.venue_order_id

class OrderEvent

Bases: Event

The abstract base class for all order events.

Warning

This class should not be used directly, but through a concrete subclass.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderEvent.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderEvent.client_order_id

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderEvent.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderEvent.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderEvent.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderEvent.strategy_id

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderEvent.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderEvent.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderEvent.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderEvent.venue_order_id

class OrderExpired

Bases: OrderEvent

OrderExpired(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has expired at the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order expired event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderExpired.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderExpired.client_order_id

static from_dict(dict values) OrderExpired

Return an order expired event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderExpired

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderExpired.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderExpired.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderExpired.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderExpired.strategy_id

static to_dict(OrderExpired obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderExpired.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderExpired.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderExpired.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderExpired.venue_order_id

class OrderFilled

Bases: OrderEvent

OrderFilled(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id, AccountId account_id, TradeId trade_id, PositionId position_id: PositionId | None, OrderSide order_side, OrderType order_type, Quantity last_qty, Price last_px, Currency currency, Money commission, LiquiditySide liquidity_side, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False, dict info=None)

Represents an event where an order has been filled at the exchange.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).

  • account_id (AccountId) – The account ID (with the venue).

  • trade_id (TradeId) – The trade match ID (assigned by the venue).

  • position_id (PositionId or None) – The position ID associated with the order fill (assigned by the venue).

  • order_side (OrderSide {BUY, SELL}) – The execution order side.

  • order_type (OrderType) – The execution order type.

  • last_qty (Quantity) – The fill quantity for this execution.

  • last_px (Price) – The fill price for this execution (not average price).

  • currency (Currency) – The currency of the price.

  • commission (Money) – The fill commission.

  • liquidity_side (LiquiditySide {NO_LIQUIDITY_SIDE, MAKER, TAKER}) – The execution liquidity side.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order filled event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • info (dict[str, object], optional) – The additional fill information.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

Raises:
  • ValueError – If order_side is NO_ORDER_SIDE.

  • ValueError – If last_qty is not positive (> 0).

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderFilled.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderFilled.client_order_id

commission

The commission generated from the fill.

Returns:

Money

currency

The currency of the price.

Returns:

Currency

static from_dict(dict values) OrderFilled

Return an order filled event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderFilled

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderFilled.id

info

The additional fill information.

Returns:

dict[str, object]

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderFilled.instrument_id

is_buy

Return whether the fill order side is BUY.

Return type:

bool

is_sell

Return whether the fill order side is SELL.

Return type:

bool

last_px

The fill price for this execution.

Returns:

Price

last_qty

The fill quantity.

Returns:

Quantity

liquidity_side

The liquidity side of the event {MAKER, TAKER}.

Returns:

LiquiditySide

order_side

The order side.

Returns:

OrderSide

order_type

The order type.

Returns:

OrderType

position_id

The position ID (assigned by the venue).

Returns:

PositionId or None

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderFilled.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderFilled.strategy_id

static to_dict(OrderFilled obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trade_id

The trade match ID (assigned by the venue).

Returns:

TradeId

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderFilled.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderFilled.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderFilled.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderFilled.venue_order_id

class OrderInitialized

Bases: OrderEvent

OrderInitialized(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, OrderType order_type, Quantity quantity, TimeInForce time_in_force, bool post_only, bool reduce_only, bool quote_quantity, dict options, TriggerType emulation_trigger, InstrumentId trigger_instrument_id: InstrumentId | None, ContingencyType contingency_type, OrderListId order_list_id: OrderListId | None, list linked_order_ids: list[ClientOrderId] | None, ClientOrderId parent_order_id: ClientOrderId | None, ExecAlgorithmId exec_algorithm_id: ExecAlgorithmId | None, dict exec_algorithm_params: dict[str, object] | None, ClientOrderId exec_spawn_id: ClientOrderId | None, list tags: list[str] | None, UUID4 event_id, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has been initialized.

This is a seed event which can instantiate any order through a creation method. This event should contain enough information to be able to send it ‘over the wire’ and have a valid order created with exactly the same properties as if it had been instantiated locally.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • order_side (OrderSide {BUY, SELL}) – The order side.

  • order_type (OrderType) – The order type.

  • quantity (Quantity) – The order quantity.

  • time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY, AT_THE_OPEN, AT_THE_CLOSE}) – The order time in force.

  • post_only (bool) – If the order will only provide liquidity (make a market).

  • reduce_only (bool) – If the order carries the ‘reduce-only’ execution instruction.

  • quote_quantity (bool) – If the order quantity is denominated in the quote currency.

  • options (dict[str, str]) – The order initialization options. Contains mappings for specific order parameters.

  • emulation_trigger (TriggerType, default NO_TRIGGER) – The type of market price trigger to use for local order emulation. - NO_TRIGGER (default): Disables local emulation; orders are sent directly to the venue. - DEFAULT (the same as BID_ASK): Enables local order emulation by triggering orders based on bid/ask prices. Additional trigger types are available. See the “Emulated Orders” section in the documentation for more details.

  • trigger_instrument_id (InstrumentId or None) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).

  • contingency_type (ContingencyType) – The order contingency type.

  • order_list_id (OrderListId or None) – The order list ID associated with the order.

  • linked_order_ids (list[ClientOrderId] or None) – The order linked client order ID(s).

  • parent_order_id (ClientOrderId or None) – The orders parent client order ID.

  • exec_algorithm_id (ExecAlgorithmId or None) – The execution algorithm ID for the order.

  • exec_algorithm_params (dict[str, Any], optional) – The execution algorithm parameters for the order.

  • exec_spawn_id (ClientOrderId or None) – The execution algorithm spawning primary client order ID.

  • tags (list[str] or None) – The custom user tags for the order.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

Raises:
  • ValueError – If order_side is NO_ORDER_SIDE.

  • ValueError – If contingency_type is not NO_CONTINGENCY, and linked_order_ids is None or empty.

  • ValueError – If exec_algorithm_id is not None, and exec_spawn_id is None.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderInitialized.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderInitialized.client_order_id

contingency_type

The orders contingency type.

Returns:

ContingencyType

emulation_trigger

The order emulation trigger type.

Returns:

TriggerType

exec_algorithm_id

The execution algorithm ID for the order.

Returns:

ExecAlgorithmId or None

exec_algorithm_params

The execution algorithm parameters for the order.

Returns:

dict[str, Any] or None

exec_spawn_id

The execution algorithm spawning client order ID.

Returns:

ClientOrderId or None

static from_dict(dict values) OrderInitialized

Return an order initialized event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderInitialized

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderInitialized.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderInitialized.instrument_id

linked_order_ids

The orders linked client order ID(s).

Returns:

list[ClientOrderId] or None

options

The order initialization options.

Returns:

dict

order_list_id

The order list ID associated with the order.

Returns:

OrderListId or None

order_type

The order type.

Returns:

OrderType

parent_order_id

The orders parent client order ID.

Returns:

ClientOrderId or None

post_only

If the order will only provide liquidity (make a market).

Returns:

bool

quantity

The order quantity.

Returns:

Quantity

quote_quantity

If the order quantity is denominated in the quote currency.

Returns:

bool

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderInitialized.reconciliation

reduce_only

If the order carries the ‘reduce-only’ execution instruction.

Returns:

bool

set_client_order_id(self, ClientOrderId client_order_id)
side

The order side.

Returns:

OrderSide

strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderInitialized.strategy_id

tags

The order custom user tags.

Returns:

list[str] or None

time_in_force

The order time in force.

Returns:

TimeInForce

static to_dict(OrderInitialized obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderInitialized.trader_id

trigger_instrument_id

The order emulation trigger instrument ID (will be instrument_id if None).

Returns:

InstrumentId or None

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderInitialized.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderInitialized.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderInitialized.venue_order_id

class OrderModifyRejected

Bases: OrderEvent

OrderModifyRejected(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, str reason, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where a ModifyOrder command has been rejected by the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • reason (str) – The order update rejected reason.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order update rejected event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderModifyRejected.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderModifyRejected.client_order_id

static from_dict(dict values) OrderModifyRejected

Return an order update rejected event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderModifyRejected

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderModifyRejected.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderModifyRejected.instrument_id

reason

str

Return the reason the order was rejected.

Return type:

str

Type:

OrderModifyRejected.reason

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderModifyRejected.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderModifyRejected.strategy_id

static to_dict(OrderModifyRejected obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderModifyRejected.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderModifyRejected.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderModifyRejected.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderModifyRejected.venue_order_id

class OrderPendingCancel

Bases: OrderEvent

OrderPendingCancel(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where a CancelOrder command has been sent to the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order pending cancel event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderPendingCancel.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderPendingCancel.client_order_id

static from_dict(dict values) OrderPendingCancel

Return an order pending cancel event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderPendingCancel

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderPendingCancel.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderPendingCancel.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderPendingCancel.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderPendingCancel.strategy_id

static to_dict(OrderPendingCancel obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderPendingCancel.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderPendingCancel.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderPendingCancel.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderPendingCancel.venue_order_id

class OrderPendingUpdate

Bases: OrderEvent

OrderPendingUpdate(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an ModifyOrder command has been sent to the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order pending update event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderPendingUpdate.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderPendingUpdate.client_order_id

static from_dict(dict values) OrderPendingUpdate

Return an order pending update event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderPendingUpdate

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderPendingUpdate.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderPendingUpdate.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderPendingUpdate.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderPendingUpdate.strategy_id

static to_dict(OrderPendingUpdate obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderPendingUpdate.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderPendingUpdate.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderPendingUpdate.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderPendingUpdate.venue_order_id

class OrderRejected

Bases: OrderEvent

OrderRejected(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, AccountId account_id, str reason, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False, bool due_post_only=False)

Represents an event where an order has been rejected by the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • account_id (AccountId) – The account ID (with the venue).

  • reason (str) – The order rejected reason.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order rejected event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

  • due_post_only (bool, default False) – If the order was rejected because it was post-only and would execute immediately as a taker.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderRejected.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderRejected.client_order_id

due_post_only

bool

If the order was rejected because it was post-only and would execute immediately as a taker.

Return type:

bool

Type:

OrderRejected.due_post_only

static from_dict(dict values) OrderRejected

Return an order rejected event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderRejected

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderRejected.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderRejected.instrument_id

reason

str

Return the reason the order was rejected.

Return type:

str

Type:

OrderRejected.reason

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderRejected.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderRejected.strategy_id

static to_dict(OrderRejected obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderRejected.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderRejected.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderRejected.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderRejected.venue_order_id

class OrderReleased

Bases: OrderEvent

OrderReleased(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, Price released_price, UUID4 event_id, uint64_t ts_init)

Represents an event where an order was released from the OrderEmulator by the Nautilus system.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • released_price (Price) – The price which released the order from the emulator.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderReleased.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderReleased.client_order_id

static from_dict(dict values) OrderReleased

Return an order released event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderReleased

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderReleased.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderReleased.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderReleased.reconciliation

released_price

Price

The released price for the event.

Return type:

Price

Type:

OrderReleased.released_price

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderReleased.strategy_id

static to_dict(OrderReleased obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderReleased.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderReleased.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderReleased.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderReleased.venue_order_id

class OrderSubmitted

Bases: OrderEvent

OrderSubmitted(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, AccountId account_id, UUID4 event_id, uint64_t ts_event, uint64_t ts_init)

Represents an event where an order has been submitted by the system to the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • account_id (AccountId) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order submitted event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderSubmitted.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderSubmitted.client_order_id

static from_dict(dict values) OrderSubmitted

Return an order submitted event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderSubmitted

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderSubmitted.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderSubmitted.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderSubmitted.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderSubmitted.strategy_id

static to_dict(OrderSubmitted obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderSubmitted.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderSubmitted.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderSubmitted.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderSubmitted.venue_order_id

class OrderTriggered

Bases: OrderEvent

OrderTriggered(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has triggered.

Applicable to StopLimit orders only.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order triggered event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderTriggered.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderTriggered.client_order_id

static from_dict(dict values) OrderTriggered

Return an order triggered event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderTriggered

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderTriggered.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderTriggered.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderTriggered.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderTriggered.strategy_id

static to_dict(OrderTriggered obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderTriggered.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderTriggered.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderTriggered.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderTriggered.venue_order_id

class OrderUpdated

Bases: OrderEvent

OrderUpdated(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, Quantity quantity, Price price: Price | None, Price trigger_price: Price | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has been updated at the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • quantity (Quantity) – The orders current quantity.

  • price (Price or None) – The orders current price.

  • trigger_price (Price or None) – The orders current trigger.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order updated event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

Raises:

ValueError – If quantity is not positive (> 0).

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderUpdated.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderUpdated.client_order_id

static from_dict(dict values) OrderUpdated

Return an order updated event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderUpdated

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderUpdated.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderUpdated.instrument_id

price

The orders current price.

Returns:

Price

quantity

The orders current quantity.

Returns:

Quantity

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderUpdated.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderUpdated.strategy_id

static to_dict(OrderUpdated obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderUpdated.trader_id

trigger_price

The orders current trigger price.

Returns:

Price or None

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderUpdated.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderUpdated.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderUpdated.venue_order_id

class PositionAdjusted

Bases: Event

PositionAdjusted(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, PositionAdjustmentType adjustment_type, quantity_change, Money pnl_change: Money | None, str reason: str | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init) -> None

Represents an adjustment to a position’s quantity or realized PnL.

This event is used to track changes to positions that occur outside of normal order fills, such as commission adjustments or funding payments.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position ID.

  • account_id (AccountId) – The account ID.

  • adjustment_type (PositionAdjustmentType) – The type of adjustment.

  • quantity_change (Decimal | None) – The quantity change (positive increases quantity, negative decreases).

  • pnl_change (Money | None) – The PnL change.

  • reason (str | None) – Optional reason or reference for the adjustment.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

The account ID associated with the adjustment.

Returns:

AccountId

adjustment_type

The type of adjustment.

Returns:

PositionAdjustmentType

static from_dict(dict values) PositionAdjusted

Return a position adjustment event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

PositionAdjusted

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

PositionAdjusted.id

instrument_id

The instrument ID associated with the event.

Returns:

InstrumentId

pnl_change

The PnL change.

Returns:

Money or None

position_id

The position ID associated with the event.

Returns:

PositionId

quantity_change

The quantity change (can be negative).

Returns:

Decimal or None

reason

Optional reason for the adjustment.

Returns:

str or None

strategy_id

The strategy ID associated with the event.

Returns:

StrategyId

static to_dict(PositionAdjusted obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

The trader ID associated with the event.

Returns:

TraderId

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

PositionAdjusted.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

PositionAdjusted.ts_init

class PositionChanged

Bases: PositionEvent

PositionChanged(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, OrderSide entry, PositionSide side, double signed_qty, Quantity quantity, Quantity peak_qty, Quantity last_qty, Price last_px, Currency currency, double avg_px_open, double avg_px_close, double realized_return, Money realized_pnl, Money unrealized_pnl, UUID4 event_id, uint64_t ts_opened, uint64_t ts_event, uint64_t ts_init)

Represents an event where a position has changed.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position IDt.

  • account_id (AccountId) – The strategy ID.

  • opening_order_id (ClientOrderId) – The client order ID for the order which opened the position.

  • strategy_id – The strategy ID associated with the event.

  • entry (OrderSide {BUY, SELL}) – The position entry order side.

  • side (PositionSide {FLAT, LONG, SHORT}) – The current position side.

  • signed_qty (double) – The current signed quantity (positive for LONG, negative for SHORT).

  • quantity (Quantity) – The current open quantity.

  • peak_qty (Quantity) – The peak directional quantity reached by the position.

  • last_qty (Quantity) – The last fill quantity for the position.

  • last_px (Price) – The last fill price for the position (not average price).

  • currency (Currency) – The position quote currency.

  • avg_px_open (double) – The average open price.

  • avg_px_close (double) – The average close price.

  • realized_return (double) – The realized return for the position.

  • realized_pnl (Money) – The realized PnL for the position.

  • unrealized_pnl (Money) – The unrealized PnL for the position.

  • event_id (UUID4) – The event ID.

  • ts_opened (uint64_t) – UNIX timestamp (nanoseconds) when the position opened event occurred.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the position changed event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

static create(Position position, OrderFilled fill, UUID4 event_id, uint64_t ts_init)

Return a position changed event from the given params.

Parameters:
  • position (Position) – The position for the event.

  • fill (OrderFilled) – The order fill for the event.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

PositionChanged

static from_dict(dict values) PositionChanged

Return a position changed event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

PositionChanged

static to_dict(PositionChanged obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

class PositionClosed

Bases: PositionEvent

PositionClosed(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, ClientOrderId closing_order_id, OrderSide entry, PositionSide side, double signed_qty, Quantity quantity, Quantity peak_qty, Quantity last_qty, Price last_px, Currency currency, double avg_px_open, double avg_px_close, double realized_return, Money realized_pnl, UUID4 event_id, uint64_t ts_opened, uint64_t ts_closed, uint64_t duration_ns, uint64_t ts_init)

Represents an event where a position has been closed.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position IDt.

  • account_id (AccountId) – The strategy ID.

  • opening_order_id (ClientOrderId) – The client order ID for the order which opened the position.

  • closing_order_id (ClientOrderId) – The client order ID for the order which closed the position.

  • strategy_id – The strategy ID associated with the event.

  • entry (OrderSide {BUY, SELL}) – The position entry order side.

  • side (PositionSide {FLAT}) – The current position side.

  • signed_qty (double) – The current signed quantity (positive for LONG, negative for SHORT).

  • quantity (Quantity) – The current open quantity.

  • peak_qty (Quantity) – The peak directional quantity reached by the position.

  • last_qty (Quantity) – The last fill quantity for the position.

  • last_px (Price) – The last fill price for the position (not average price).

  • currency (Currency) – The position quote currency.

  • avg_px_open (Decimal) – The average open price.

  • avg_px_close (Decimal) – The average close price.

  • realized_return (Decimal) – The realized return for the position.

  • realized_pnl (Money) – The realized PnL for the position.

  • event_id (UUID4) – The event ID.

  • ts_opened (uint64_t) – UNIX timestamp (nanoseconds) when the position opened event occurred.

  • ts_closed (uint64_t) – UNIX timestamp (nanoseconds) when the position closed event occurred.

  • duration_ns (uint64_t) – The total open duration (nanoseconds).

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

static create(Position position, OrderFilled fill, UUID4 event_id, uint64_t ts_init)

Return a position closed event from the given params.

Parameters:
  • position (Position) – The position for the event.

  • fill (OrderFilled) – The order fill for the event.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

PositionClosed

static from_dict(dict values) PositionClosed

Return a position closed event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

PositionClosed

static to_dict(PositionClosed obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

class PositionEvent

Bases: Event

PositionEvent(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, ClientOrderId closing_order_id: ClientOrderId | None, OrderSide entry, PositionSide side, double signed_qty, Quantity quantity, Quantity peak_qty, Quantity last_qty, Price last_px, Currency currency, double avg_px_open, double avg_px_close, double realized_return, Money realized_pnl, Money unrealized_pnl, UUID4 event_id, uint64_t ts_opened, uint64_t ts_closed, uint64_t duration_ns, uint64_t ts_event, uint64_t ts_init)

The base class for all position events.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position IDt.

  • account_id (AccountId) – The strategy ID.

  • opening_order_id (ClientOrderId) – The client order ID for the order which opened the position.

  • closing_order_id (ClientOrderId) – The client order ID for the order which closed the position.

  • entry (OrderSide {BUY, SELL}) – The position entry order side.

  • side (PositionSide {FLAT, LONG, SHORT}) – The current position side.

  • signed_qty (double) – The current signed quantity (positive for LONG, negative for SHORT).

  • quantity (Quantity) – The current open quantity.

  • peak_qty (Quantity) – The peak directional quantity reached by the position.

  • last_qty (Quantity) – The last fill quantity for the position.

  • last_px (Price) – The last fill price for the position (not average price).

  • currency (Currency) – The position quote currency.

  • avg_px_open (double) – The average open price.

  • avg_px_close (double) – The average close price.

  • realized_return (double) – The realized return for the position.

  • realized_pnl (Money) – The realized PnL for the position.

  • unrealized_pnl (Money) – The unrealized PnL for the position.

  • event_id (UUID4) – The event ID.

  • ts_opened (uint64_t) – UNIX timestamp (nanoseconds) when the position opened event occurred.

  • ts_closed (uint64_t) – UNIX timestamp (nanoseconds) when the position closed event occurred.

  • duration_ns (uint64_t) – The total open duration (nanoseconds), will be 0 if still open.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Warning

This class should not be used directly, but through a concrete subclass.

account_id

The account ID associated with the position.

Returns:

AccountId

avg_px_close

The average closing price.

Returns:

double

avg_px_open

The average open price.

Returns:

double

closing_order_id

The client order ID for the order which closed the position.

Returns:

ClientOrderId or None

currency

The position quote currency.

Returns:

Currency

duration_ns

The total open duration (nanoseconds).

Returns:

uint64_t

entry

The entry direction from open.

Returns:

OrderSide

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

PositionEvent.id

instrument_id

The instrument ID associated with the event.

Returns:

InstrumentId

last_px

The last fill price for the position.

Returns:

Price

last_qty

The last fill quantity for the position.

Returns:

Quantity

opening_order_id

The client order ID for the order which opened the position.

Returns:

ClientOrderId

peak_qty

The peak directional quantity reached by the position.

Returns:

Quantity

position_id

The position ID associated with the event.

Returns:

PositionId

quantity

The position open quantity.

Returns:

Quantity

realized_pnl

The realized PnL for the position (including commissions).

Returns:

Money

realized_return

The realized return for the position.

Returns:

double

side

The position side.

Returns:

PositionSide

signed_qty

The position signed quantity (positive for LONG, negative for SHORT).

Returns:

double

strategy_id

The strategy ID associated with the event.

Returns:

StrategyId

trader_id

The trader ID associated with the event.

Returns:

TraderId

ts_closed

UNIX timestamp (nanoseconds) when the position was closed.

Returns:

uint64_t

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

PositionEvent.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

PositionEvent.ts_init

ts_opened

UNIX timestamp (nanoseconds) when the position was opened.

Returns:

uint64_t

unrealized_pnl

The unrealized PnL for the position (including commissions).

Returns:

Money

class PositionOpened

Bases: PositionEvent

PositionOpened(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, OrderSide entry, PositionSide side, double signed_qty, Quantity quantity, Quantity peak_qty, Quantity last_qty, Price last_px, Currency currency, double avg_px_open, Money realized_pnl, UUID4 event_id, uint64_t ts_event, uint64_t ts_init)

Represents an event where a position has been opened.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position IDt.

  • account_id (AccountId) – The strategy ID.

  • opening_order_id (ClientOrderId) – The client order ID for the order which opened the position.

  • strategy_id – The strategy ID associated with the event.

  • entry (OrderSide {BUY, SELL}) – The position entry order side.

  • side (PositionSide {LONG, SHORT}) – The current position side.

  • signed_qty (double) – The current signed quantity (positive for LONG, negative for SHORT).

  • quantity (Quantity) – The current open quantity.

  • peak_qty (Quantity) – The peak directional quantity reached by the position.

  • last_qty (Quantity) – The last fill quantity for the position.

  • last_px (Price) – The last fill price for the position (not average price).

  • currency (Currency) – The position quote currency.

  • avg_px_open (double) – The average open price.

  • realized_pnl (Money) – The realized PnL for the position.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the position opened event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

static create(Position position, OrderFilled fill, UUID4 event_id, uint64_t ts_init)

Return a position opened event from the given params.

Parameters:
  • position (Position) – The position for the event.

  • fill (OrderFilled) – The order fill for the event.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

PositionOpened

static from_dict(dict values) PositionOpened

Return a position opened event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

PositionOpened

static to_dict(PositionOpened obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

class AccountState

Bases: Event

AccountState(AccountId account_id, AccountType account_type, Currency base_currency, bool reported, list balances, list margins, dict info, UUID4 event_id, uint64_t ts_event, uint64_t ts_init)

Represents an event which includes information on the state of the account.

Parameters:
  • account_id (AccountId) – The account ID (with the venue).

  • account_type (AccountType) – The account type for the event.

  • base_currency (Currency, optional) – The account base currency. Use None for multi-currency accounts.

  • reported (bool) – If the state is reported from the exchange (otherwise system calculated).

  • balances (list[AccountBalance]) – The account balances.

  • margins (list[MarginBalance]) – The margin balances (can be empty).

  • info (dict [str, object]) – The additional implementation specific account information.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the account state event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Raises:

ValueError – If balances is empty.

account_id

The account ID associated with the event.

Returns:

AccountId

account_type

The account type for the event.

Returns:

AccountType

balances

The account balances.

Returns:

list[AccountBalance]

base_currency

The account type for the event.

Returns:

Currency or None

static from_dict(dict values) AccountState

Return an account state event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

AccountState

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

AccountState.id

info

The additional implementation specific account information.

Returns:

dict[str, object]

is_reported

If the state is reported from the exchange (otherwise system calculated).

Returns:

bool

margins

The margin balances.

Returns:

list[MarginBalance]

static to_dict(AccountState obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

AccountState.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

AccountState.ts_init

class OrderAccepted

Bases: OrderEvent

OrderAccepted(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id, AccountId account_id, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has been accepted by the trading venue.

This event often corresponds to a NEW OrdStatus <39> field in FIX execution reports.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).

  • account_id (AccountId) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order accepted event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderAccepted.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderAccepted.client_order_id

static from_dict(dict values) OrderAccepted

Return an order accepted event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderAccepted

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderAccepted.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderAccepted.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderAccepted.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderAccepted.strategy_id

static to_dict(OrderAccepted obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderAccepted.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderAccepted.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderAccepted.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderAccepted.venue_order_id

class OrderCancelRejected

Bases: OrderEvent

OrderCancelRejected(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, str reason, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where a CancelOrder command has been rejected by the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • reason (str) – The order cancel rejected reason.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order cancel rejected event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderCancelRejected.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderCancelRejected.client_order_id

static from_dict(dict values) OrderCancelRejected

Return an order cancel rejected event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderCancelRejected

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderCancelRejected.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderCancelRejected.instrument_id

reason

str

Return the reason the order was rejected.

Return type:

str

Type:

OrderCancelRejected.reason

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderCancelRejected.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderCancelRejected.strategy_id

static to_dict(OrderCancelRejected obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderCancelRejected.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderCancelRejected.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderCancelRejected.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderCancelRejected.venue_order_id

class OrderCanceled

Bases: OrderEvent

OrderCanceled(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has been canceled at the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when order canceled event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderCanceled.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderCanceled.client_order_id

static from_dict(dict values) OrderCanceled

Return an order canceled event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderCanceled

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderCanceled.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderCanceled.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderCanceled.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderCanceled.strategy_id

static to_dict(OrderCanceled obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderCanceled.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderCanceled.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderCanceled.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderCanceled.venue_order_id

class OrderDenied

Bases: OrderEvent

OrderDenied(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, str reason, UUID4 event_id, uint64_t ts_init)

Represents an event where an order has been denied by the Nautilus system.

This could be due an unsupported feature, a risk limit exceedance, or for any other reason that an otherwise valid order is not able to be submitted.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • reason (str) – The order denied reason.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderDenied.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderDenied.client_order_id

static from_dict(dict values) OrderDenied

Return an order denied event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderDenied

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderDenied.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderDenied.instrument_id

reason

str

Return the reason the order was denied.

Return type:

str

Type:

OrderDenied.reason

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderDenied.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderDenied.strategy_id

static to_dict(OrderDenied obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderDenied.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderDenied.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderDenied.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderDenied.venue_order_id

class OrderEmulated

Bases: OrderEvent

OrderEmulated(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, UUID4 event_id, uint64_t ts_init)

Represents an event where an order has become emulated by the Nautilus system.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderEmulated.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderEmulated.client_order_id

static from_dict(dict values) OrderEmulated

Return an order emulated event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderEmulated

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderEmulated.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderEmulated.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderEmulated.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderEmulated.strategy_id

static to_dict(OrderEmulated obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderEmulated.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderEmulated.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderEmulated.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderEmulated.venue_order_id

class OrderEvent

Bases: Event

The abstract base class for all order events.

Warning

This class should not be used directly, but through a concrete subclass.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderEvent.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderEvent.client_order_id

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderEvent.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderEvent.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderEvent.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderEvent.strategy_id

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderEvent.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderEvent.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderEvent.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderEvent.venue_order_id

class OrderExpired

Bases: OrderEvent

OrderExpired(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has expired at the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order expired event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderExpired.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderExpired.client_order_id

static from_dict(dict values) OrderExpired

Return an order expired event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderExpired

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderExpired.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderExpired.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderExpired.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderExpired.strategy_id

static to_dict(OrderExpired obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderExpired.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderExpired.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderExpired.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderExpired.venue_order_id

class OrderFilled

Bases: OrderEvent

OrderFilled(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id, AccountId account_id, TradeId trade_id, PositionId position_id: PositionId | None, OrderSide order_side, OrderType order_type, Quantity last_qty, Price last_px, Currency currency, Money commission, LiquiditySide liquidity_side, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False, dict info=None)

Represents an event where an order has been filled at the exchange.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId) – The venue order ID (assigned by the venue).

  • account_id (AccountId) – The account ID (with the venue).

  • trade_id (TradeId) – The trade match ID (assigned by the venue).

  • position_id (PositionId or None) – The position ID associated with the order fill (assigned by the venue).

  • order_side (OrderSide {BUY, SELL}) – The execution order side.

  • order_type (OrderType) – The execution order type.

  • last_qty (Quantity) – The fill quantity for this execution.

  • last_px (Price) – The fill price for this execution (not average price).

  • currency (Currency) – The currency of the price.

  • commission (Money) – The fill commission.

  • liquidity_side (LiquiditySide {NO_LIQUIDITY_SIDE, MAKER, TAKER}) – The execution liquidity side.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order filled event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • info (dict[str, object], optional) – The additional fill information.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

Raises:
  • ValueError – If order_side is NO_ORDER_SIDE.

  • ValueError – If last_qty is not positive (> 0).

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderFilled.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderFilled.client_order_id

commission

The commission generated from the fill.

Returns:

Money

currency

The currency of the price.

Returns:

Currency

static from_dict(dict values) OrderFilled

Return an order filled event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderFilled

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderFilled.id

info

The additional fill information.

Returns:

dict[str, object]

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderFilled.instrument_id

is_buy

Return whether the fill order side is BUY.

Return type:

bool

is_sell

Return whether the fill order side is SELL.

Return type:

bool

last_px

The fill price for this execution.

Returns:

Price

last_qty

The fill quantity.

Returns:

Quantity

liquidity_side

The liquidity side of the event {MAKER, TAKER}.

Returns:

LiquiditySide

order_side

The order side.

Returns:

OrderSide

order_type

The order type.

Returns:

OrderType

position_id

The position ID (assigned by the venue).

Returns:

PositionId or None

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderFilled.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderFilled.strategy_id

static to_dict(OrderFilled obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trade_id

The trade match ID (assigned by the venue).

Returns:

TradeId

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderFilled.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderFilled.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderFilled.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderFilled.venue_order_id

class OrderInitialized

Bases: OrderEvent

OrderInitialized(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, OrderType order_type, Quantity quantity, TimeInForce time_in_force, bool post_only, bool reduce_only, bool quote_quantity, dict options, TriggerType emulation_trigger, InstrumentId trigger_instrument_id: InstrumentId | None, ContingencyType contingency_type, OrderListId order_list_id: OrderListId | None, list linked_order_ids: list[ClientOrderId] | None, ClientOrderId parent_order_id: ClientOrderId | None, ExecAlgorithmId exec_algorithm_id: ExecAlgorithmId | None, dict exec_algorithm_params: dict[str, object] | None, ClientOrderId exec_spawn_id: ClientOrderId | None, list tags: list[str] | None, UUID4 event_id, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has been initialized.

This is a seed event which can instantiate any order through a creation method. This event should contain enough information to be able to send it ‘over the wire’ and have a valid order created with exactly the same properties as if it had been instantiated locally.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • order_side (OrderSide {BUY, SELL}) – The order side.

  • order_type (OrderType) – The order type.

  • quantity (Quantity) – The order quantity.

  • time_in_force (TimeInForce {GTC, IOC, FOK, GTD, DAY, AT_THE_OPEN, AT_THE_CLOSE}) – The order time in force.

  • post_only (bool) – If the order will only provide liquidity (make a market).

  • reduce_only (bool) – If the order carries the ‘reduce-only’ execution instruction.

  • quote_quantity (bool) – If the order quantity is denominated in the quote currency.

  • options (dict[str, str]) – The order initialization options. Contains mappings for specific order parameters.

  • emulation_trigger (TriggerType, default NO_TRIGGER) – The type of market price trigger to use for local order emulation. - NO_TRIGGER (default): Disables local emulation; orders are sent directly to the venue. - DEFAULT (the same as BID_ASK): Enables local order emulation by triggering orders based on bid/ask prices. Additional trigger types are available. See the “Emulated Orders” section in the documentation for more details.

  • trigger_instrument_id (InstrumentId or None) – The emulation trigger instrument ID for the order (if None then will be the instrument_id).

  • contingency_type (ContingencyType) – The order contingency type.

  • order_list_id (OrderListId or None) – The order list ID associated with the order.

  • linked_order_ids (list[ClientOrderId] or None) – The order linked client order ID(s).

  • parent_order_id (ClientOrderId or None) – The orders parent client order ID.

  • exec_algorithm_id (ExecAlgorithmId or None) – The execution algorithm ID for the order.

  • exec_algorithm_params (dict[str, Any], optional) – The execution algorithm parameters for the order.

  • exec_spawn_id (ClientOrderId or None) – The execution algorithm spawning primary client order ID.

  • tags (list[str] or None) – The custom user tags for the order.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

Raises:
  • ValueError – If order_side is NO_ORDER_SIDE.

  • ValueError – If contingency_type is not NO_CONTINGENCY, and linked_order_ids is None or empty.

  • ValueError – If exec_algorithm_id is not None, and exec_spawn_id is None.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderInitialized.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderInitialized.client_order_id

contingency_type

The orders contingency type.

Returns:

ContingencyType

emulation_trigger

The order emulation trigger type.

Returns:

TriggerType

exec_algorithm_id

The execution algorithm ID for the order.

Returns:

ExecAlgorithmId or None

exec_algorithm_params

The execution algorithm parameters for the order.

Returns:

dict[str, Any] or None

exec_spawn_id

The execution algorithm spawning client order ID.

Returns:

ClientOrderId or None

static from_dict(dict values) OrderInitialized

Return an order initialized event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderInitialized

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderInitialized.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderInitialized.instrument_id

linked_order_ids

The orders linked client order ID(s).

Returns:

list[ClientOrderId] or None

options

The order initialization options.

Returns:

dict

order_list_id

The order list ID associated with the order.

Returns:

OrderListId or None

order_type

The order type.

Returns:

OrderType

parent_order_id

The orders parent client order ID.

Returns:

ClientOrderId or None

post_only

If the order will only provide liquidity (make a market).

Returns:

bool

quantity

The order quantity.

Returns:

Quantity

quote_quantity

If the order quantity is denominated in the quote currency.

Returns:

bool

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderInitialized.reconciliation

reduce_only

If the order carries the ‘reduce-only’ execution instruction.

Returns:

bool

set_client_order_id(self, ClientOrderId client_order_id)
side

The order side.

Returns:

OrderSide

strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderInitialized.strategy_id

tags

The order custom user tags.

Returns:

list[str] or None

time_in_force

The order time in force.

Returns:

TimeInForce

static to_dict(OrderInitialized obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderInitialized.trader_id

trigger_instrument_id

The order emulation trigger instrument ID (will be instrument_id if None).

Returns:

InstrumentId or None

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderInitialized.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderInitialized.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderInitialized.venue_order_id

class OrderModifyRejected

Bases: OrderEvent

OrderModifyRejected(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, str reason, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where a ModifyOrder command has been rejected by the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • reason (str) – The order update rejected reason.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order update rejected event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderModifyRejected.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderModifyRejected.client_order_id

static from_dict(dict values) OrderModifyRejected

Return an order update rejected event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderModifyRejected

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderModifyRejected.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderModifyRejected.instrument_id

reason

str

Return the reason the order was rejected.

Return type:

str

Type:

OrderModifyRejected.reason

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderModifyRejected.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderModifyRejected.strategy_id

static to_dict(OrderModifyRejected obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderModifyRejected.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderModifyRejected.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderModifyRejected.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderModifyRejected.venue_order_id

class OrderPendingCancel

Bases: OrderEvent

OrderPendingCancel(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where a CancelOrder command has been sent to the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order pending cancel event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderPendingCancel.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderPendingCancel.client_order_id

static from_dict(dict values) OrderPendingCancel

Return an order pending cancel event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderPendingCancel

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderPendingCancel.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderPendingCancel.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderPendingCancel.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderPendingCancel.strategy_id

static to_dict(OrderPendingCancel obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderPendingCancel.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderPendingCancel.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderPendingCancel.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderPendingCancel.venue_order_id

class OrderPendingUpdate

Bases: OrderEvent

OrderPendingUpdate(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an ModifyOrder command has been sent to the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order pending update event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderPendingUpdate.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderPendingUpdate.client_order_id

static from_dict(dict values) OrderPendingUpdate

Return an order pending update event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderPendingUpdate

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderPendingUpdate.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderPendingUpdate.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderPendingUpdate.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderPendingUpdate.strategy_id

static to_dict(OrderPendingUpdate obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderPendingUpdate.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderPendingUpdate.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderPendingUpdate.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderPendingUpdate.venue_order_id

class OrderRejected

Bases: OrderEvent

OrderRejected(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, AccountId account_id, str reason, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False, bool due_post_only=False)

Represents an event where an order has been rejected by the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • account_id (AccountId) – The account ID (with the venue).

  • reason (str) – The order rejected reason.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order rejected event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

  • due_post_only (bool, default False) – If the order was rejected because it was post-only and would execute immediately as a taker.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderRejected.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderRejected.client_order_id

due_post_only

bool

If the order was rejected because it was post-only and would execute immediately as a taker.

Return type:

bool

Type:

OrderRejected.due_post_only

static from_dict(dict values) OrderRejected

Return an order rejected event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderRejected

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderRejected.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderRejected.instrument_id

reason

str

Return the reason the order was rejected.

Return type:

str

Type:

OrderRejected.reason

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderRejected.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderRejected.strategy_id

static to_dict(OrderRejected obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderRejected.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderRejected.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderRejected.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderRejected.venue_order_id

class OrderReleased

Bases: OrderEvent

OrderReleased(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, Price released_price, UUID4 event_id, uint64_t ts_init)

Represents an event where an order was released from the OrderEmulator by the Nautilus system.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • released_price (Price) – The price which released the order from the emulator.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderReleased.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderReleased.client_order_id

static from_dict(dict values) OrderReleased

Return an order released event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderReleased

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderReleased.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderReleased.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderReleased.reconciliation

released_price

Price

The released price for the event.

Return type:

Price

Type:

OrderReleased.released_price

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderReleased.strategy_id

static to_dict(OrderReleased obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderReleased.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderReleased.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderReleased.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderReleased.venue_order_id

class OrderSubmitted

Bases: OrderEvent

OrderSubmitted(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, AccountId account_id, UUID4 event_id, uint64_t ts_event, uint64_t ts_init)

Represents an event where an order has been submitted by the system to the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • account_id (AccountId) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order submitted event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderSubmitted.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderSubmitted.client_order_id

static from_dict(dict values) OrderSubmitted

Return an order submitted event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderSubmitted

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderSubmitted.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderSubmitted.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderSubmitted.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderSubmitted.strategy_id

static to_dict(OrderSubmitted obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderSubmitted.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderSubmitted.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderSubmitted.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderSubmitted.venue_order_id

class OrderTriggered

Bases: OrderEvent

OrderTriggered(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has triggered.

Applicable to StopLimit orders only.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order triggered event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderTriggered.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderTriggered.client_order_id

static from_dict(dict values) OrderTriggered

Return an order triggered event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderTriggered

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderTriggered.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderTriggered.instrument_id

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderTriggered.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderTriggered.strategy_id

static to_dict(OrderTriggered obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderTriggered.trader_id

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderTriggered.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderTriggered.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderTriggered.venue_order_id

class OrderUpdated

Bases: OrderEvent

OrderUpdated(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: VenueOrderId | None, AccountId account_id: AccountId | None, Quantity quantity, Price price: Price | None, Price trigger_price: Price | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False)

Represents an event where an order has been updated at the trading venue.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • client_order_id (ClientOrderId) – The client order ID.

  • venue_order_id (VenueOrderId or None) – The venue order ID (assigned by the venue).

  • account_id (AccountId or None) – The account ID (with the venue).

  • quantity (Quantity) – The orders current quantity.

  • price (Price or None) – The orders current price.

  • trigger_price (Price or None) – The orders current trigger.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the order updated event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

  • reconciliation (bool, default False) – If the event was generated during reconciliation.

Raises:

ValueError – If quantity is not positive (> 0).

account_id

AccountId | None

The account ID associated with the event.

Return type:

AccountId or None

Type:

OrderUpdated.account_id

client_order_id

ClientOrderId

The client order ID associated with the event.

Return type:

ClientOrderId

Type:

OrderUpdated.client_order_id

static from_dict(dict values) OrderUpdated

Return an order updated event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

OrderUpdated

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

OrderUpdated.id

instrument_id

InstrumentId

The instrument ID associated with the event.

Return type:

InstrumentId

Type:

OrderUpdated.instrument_id

price

The orders current price.

Returns:

Price

quantity

The orders current quantity.

Returns:

Quantity

reconciliation

bool

If the event was generated during reconciliation.

Return type:

bool

Type:

OrderUpdated.reconciliation

set_client_order_id(self, ClientOrderId client_order_id)
strategy_id

TraderId

The strategy ID associated with the event.

Return type:

StrategyId

Type:

OrderUpdated.strategy_id

static to_dict(OrderUpdated obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

TraderId

The trader ID associated with the event.

Return type:

TraderId

Type:

OrderUpdated.trader_id

trigger_price

The orders current trigger price.

Returns:

Price or None

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

OrderUpdated.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

OrderUpdated.ts_init

venue_order_id

VenueOrderId | None

The venue order ID associated with the event.

Return type:

VenueOrderId or None

Type:

OrderUpdated.venue_order_id

class PositionAdjusted

Bases: Event

PositionAdjusted(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, PositionAdjustmentType adjustment_type, quantity_change, Money pnl_change: Money | None, str reason: str | None, UUID4 event_id, uint64_t ts_event, uint64_t ts_init) -> None

Represents an adjustment to a position’s quantity or realized PnL.

This event is used to track changes to positions that occur outside of normal order fills, such as commission adjustments or funding payments.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position ID.

  • account_id (AccountId) – The account ID.

  • adjustment_type (PositionAdjustmentType) – The type of adjustment.

  • quantity_change (Decimal | None) – The quantity change (positive increases quantity, negative decreases).

  • pnl_change (Money | None) – The PnL change.

  • reason (str | None) – Optional reason or reference for the adjustment.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

The account ID associated with the adjustment.

Returns:

AccountId

adjustment_type

The type of adjustment.

Returns:

PositionAdjustmentType

static from_dict(dict values) PositionAdjusted

Return a position adjustment event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

PositionAdjusted

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

PositionAdjusted.id

instrument_id

The instrument ID associated with the event.

Returns:

InstrumentId

pnl_change

The PnL change.

Returns:

Money or None

position_id

The position ID associated with the event.

Returns:

PositionId

quantity_change

The quantity change (can be negative).

Returns:

Decimal or None

reason

Optional reason for the adjustment.

Returns:

str or None

strategy_id

The strategy ID associated with the event.

Returns:

StrategyId

static to_dict(PositionAdjusted obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

The trader ID associated with the event.

Returns:

TraderId

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

PositionAdjusted.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

PositionAdjusted.ts_init

class PositionChanged

Bases: PositionEvent

PositionChanged(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, OrderSide entry, PositionSide side, double signed_qty, Quantity quantity, Quantity peak_qty, Quantity last_qty, Price last_px, Currency currency, double avg_px_open, double avg_px_close, double realized_return, Money realized_pnl, Money unrealized_pnl, UUID4 event_id, uint64_t ts_opened, uint64_t ts_event, uint64_t ts_init)

Represents an event where a position has changed.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position IDt.

  • account_id (AccountId) – The strategy ID.

  • opening_order_id (ClientOrderId) – The client order ID for the order which opened the position.

  • strategy_id – The strategy ID associated with the event.

  • entry (OrderSide {BUY, SELL}) – The position entry order side.

  • side (PositionSide {FLAT, LONG, SHORT}) – The current position side.

  • signed_qty (double) – The current signed quantity (positive for LONG, negative for SHORT).

  • quantity (Quantity) – The current open quantity.

  • peak_qty (Quantity) – The peak directional quantity reached by the position.

  • last_qty (Quantity) – The last fill quantity for the position.

  • last_px (Price) – The last fill price for the position (not average price).

  • currency (Currency) – The position quote currency.

  • avg_px_open (double) – The average open price.

  • avg_px_close (double) – The average close price.

  • realized_return (double) – The realized return for the position.

  • realized_pnl (Money) – The realized PnL for the position.

  • unrealized_pnl (Money) – The unrealized PnL for the position.

  • event_id (UUID4) – The event ID.

  • ts_opened (uint64_t) – UNIX timestamp (nanoseconds) when the position opened event occurred.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the position changed event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

The account ID associated with the position.

Returns:

AccountId

avg_px_close

The average closing price.

Returns:

double

avg_px_open

The average open price.

Returns:

double

closing_order_id

The client order ID for the order which closed the position.

Returns:

ClientOrderId or None

static create(Position position, OrderFilled fill, UUID4 event_id, uint64_t ts_init)

Return a position changed event from the given params.

Parameters:
  • position (Position) – The position for the event.

  • fill (OrderFilled) – The order fill for the event.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

PositionChanged

currency

The position quote currency.

Returns:

Currency

duration_ns

The total open duration (nanoseconds).

Returns:

uint64_t

entry

The entry direction from open.

Returns:

OrderSide

static from_dict(dict values) PositionChanged

Return a position changed event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

PositionChanged

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

PositionEvent.id

instrument_id

The instrument ID associated with the event.

Returns:

InstrumentId

last_px

The last fill price for the position.

Returns:

Price

last_qty

The last fill quantity for the position.

Returns:

Quantity

opening_order_id

The client order ID for the order which opened the position.

Returns:

ClientOrderId

peak_qty

The peak directional quantity reached by the position.

Returns:

Quantity

position_id

The position ID associated with the event.

Returns:

PositionId

quantity

The position open quantity.

Returns:

Quantity

realized_pnl

The realized PnL for the position (including commissions).

Returns:

Money

realized_return

The realized return for the position.

Returns:

double

side

The position side.

Returns:

PositionSide

signed_qty

The position signed quantity (positive for LONG, negative for SHORT).

Returns:

double

strategy_id

The strategy ID associated with the event.

Returns:

StrategyId

static to_dict(PositionChanged obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

The trader ID associated with the event.

Returns:

TraderId

ts_closed

UNIX timestamp (nanoseconds) when the position was closed.

Returns:

uint64_t

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

PositionEvent.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

PositionEvent.ts_init

ts_opened

UNIX timestamp (nanoseconds) when the position was opened.

Returns:

uint64_t

unrealized_pnl

The unrealized PnL for the position (including commissions).

Returns:

Money

class PositionClosed

Bases: PositionEvent

PositionClosed(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, ClientOrderId closing_order_id, OrderSide entry, PositionSide side, double signed_qty, Quantity quantity, Quantity peak_qty, Quantity last_qty, Price last_px, Currency currency, double avg_px_open, double avg_px_close, double realized_return, Money realized_pnl, UUID4 event_id, uint64_t ts_opened, uint64_t ts_closed, uint64_t duration_ns, uint64_t ts_init)

Represents an event where a position has been closed.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position IDt.

  • account_id (AccountId) – The strategy ID.

  • opening_order_id (ClientOrderId) – The client order ID for the order which opened the position.

  • closing_order_id (ClientOrderId) – The client order ID for the order which closed the position.

  • strategy_id – The strategy ID associated with the event.

  • entry (OrderSide {BUY, SELL}) – The position entry order side.

  • side (PositionSide {FLAT}) – The current position side.

  • signed_qty (double) – The current signed quantity (positive for LONG, negative for SHORT).

  • quantity (Quantity) – The current open quantity.

  • peak_qty (Quantity) – The peak directional quantity reached by the position.

  • last_qty (Quantity) – The last fill quantity for the position.

  • last_px (Price) – The last fill price for the position (not average price).

  • currency (Currency) – The position quote currency.

  • avg_px_open (Decimal) – The average open price.

  • avg_px_close (Decimal) – The average close price.

  • realized_return (Decimal) – The realized return for the position.

  • realized_pnl (Money) – The realized PnL for the position.

  • event_id (UUID4) – The event ID.

  • ts_opened (uint64_t) – UNIX timestamp (nanoseconds) when the position opened event occurred.

  • ts_closed (uint64_t) – UNIX timestamp (nanoseconds) when the position closed event occurred.

  • duration_ns (uint64_t) – The total open duration (nanoseconds).

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

The account ID associated with the position.

Returns:

AccountId

avg_px_close

The average closing price.

Returns:

double

avg_px_open

The average open price.

Returns:

double

closing_order_id

The client order ID for the order which closed the position.

Returns:

ClientOrderId or None

static create(Position position, OrderFilled fill, UUID4 event_id, uint64_t ts_init)

Return a position closed event from the given params.

Parameters:
  • position (Position) – The position for the event.

  • fill (OrderFilled) – The order fill for the event.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

PositionClosed

currency

The position quote currency.

Returns:

Currency

duration_ns

The total open duration (nanoseconds).

Returns:

uint64_t

entry

The entry direction from open.

Returns:

OrderSide

static from_dict(dict values) PositionClosed

Return a position closed event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

PositionClosed

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

PositionEvent.id

instrument_id

The instrument ID associated with the event.

Returns:

InstrumentId

last_px

The last fill price for the position.

Returns:

Price

last_qty

The last fill quantity for the position.

Returns:

Quantity

opening_order_id

The client order ID for the order which opened the position.

Returns:

ClientOrderId

peak_qty

The peak directional quantity reached by the position.

Returns:

Quantity

position_id

The position ID associated with the event.

Returns:

PositionId

quantity

The position open quantity.

Returns:

Quantity

realized_pnl

The realized PnL for the position (including commissions).

Returns:

Money

realized_return

The realized return for the position.

Returns:

double

side

The position side.

Returns:

PositionSide

signed_qty

The position signed quantity (positive for LONG, negative for SHORT).

Returns:

double

strategy_id

The strategy ID associated with the event.

Returns:

StrategyId

static to_dict(PositionClosed obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

The trader ID associated with the event.

Returns:

TraderId

ts_closed

UNIX timestamp (nanoseconds) when the position was closed.

Returns:

uint64_t

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

PositionEvent.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

PositionEvent.ts_init

ts_opened

UNIX timestamp (nanoseconds) when the position was opened.

Returns:

uint64_t

unrealized_pnl

The unrealized PnL for the position (including commissions).

Returns:

Money

class PositionEvent

Bases: Event

PositionEvent(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, ClientOrderId closing_order_id: ClientOrderId | None, OrderSide entry, PositionSide side, double signed_qty, Quantity quantity, Quantity peak_qty, Quantity last_qty, Price last_px, Currency currency, double avg_px_open, double avg_px_close, double realized_return, Money realized_pnl, Money unrealized_pnl, UUID4 event_id, uint64_t ts_opened, uint64_t ts_closed, uint64_t duration_ns, uint64_t ts_event, uint64_t ts_init)

The base class for all position events.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position IDt.

  • account_id (AccountId) – The strategy ID.

  • opening_order_id (ClientOrderId) – The client order ID for the order which opened the position.

  • closing_order_id (ClientOrderId) – The client order ID for the order which closed the position.

  • entry (OrderSide {BUY, SELL}) – The position entry order side.

  • side (PositionSide {FLAT, LONG, SHORT}) – The current position side.

  • signed_qty (double) – The current signed quantity (positive for LONG, negative for SHORT).

  • quantity (Quantity) – The current open quantity.

  • peak_qty (Quantity) – The peak directional quantity reached by the position.

  • last_qty (Quantity) – The last fill quantity for the position.

  • last_px (Price) – The last fill price for the position (not average price).

  • currency (Currency) – The position quote currency.

  • avg_px_open (double) – The average open price.

  • avg_px_close (double) – The average close price.

  • realized_return (double) – The realized return for the position.

  • realized_pnl (Money) – The realized PnL for the position.

  • unrealized_pnl (Money) – The unrealized PnL for the position.

  • event_id (UUID4) – The event ID.

  • ts_opened (uint64_t) – UNIX timestamp (nanoseconds) when the position opened event occurred.

  • ts_closed (uint64_t) – UNIX timestamp (nanoseconds) when the position closed event occurred.

  • duration_ns (uint64_t) – The total open duration (nanoseconds), will be 0 if still open.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Warning

This class should not be used directly, but through a concrete subclass.

account_id

The account ID associated with the position.

Returns:

AccountId

avg_px_close

The average closing price.

Returns:

double

avg_px_open

The average open price.

Returns:

double

closing_order_id

The client order ID for the order which closed the position.

Returns:

ClientOrderId or None

currency

The position quote currency.

Returns:

Currency

duration_ns

The total open duration (nanoseconds).

Returns:

uint64_t

entry

The entry direction from open.

Returns:

OrderSide

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

PositionEvent.id

instrument_id

The instrument ID associated with the event.

Returns:

InstrumentId

last_px

The last fill price for the position.

Returns:

Price

last_qty

The last fill quantity for the position.

Returns:

Quantity

opening_order_id

The client order ID for the order which opened the position.

Returns:

ClientOrderId

peak_qty

The peak directional quantity reached by the position.

Returns:

Quantity

position_id

The position ID associated with the event.

Returns:

PositionId

quantity

The position open quantity.

Returns:

Quantity

realized_pnl

The realized PnL for the position (including commissions).

Returns:

Money

realized_return

The realized return for the position.

Returns:

double

side

The position side.

Returns:

PositionSide

signed_qty

The position signed quantity (positive for LONG, negative for SHORT).

Returns:

double

strategy_id

The strategy ID associated with the event.

Returns:

StrategyId

trader_id

The trader ID associated with the event.

Returns:

TraderId

ts_closed

UNIX timestamp (nanoseconds) when the position was closed.

Returns:

uint64_t

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

PositionEvent.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

PositionEvent.ts_init

ts_opened

UNIX timestamp (nanoseconds) when the position was opened.

Returns:

uint64_t

unrealized_pnl

The unrealized PnL for the position (including commissions).

Returns:

Money

class PositionOpened

Bases: PositionEvent

PositionOpened(TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, OrderSide entry, PositionSide side, double signed_qty, Quantity quantity, Quantity peak_qty, Quantity last_qty, Price last_px, Currency currency, double avg_px_open, Money realized_pnl, UUID4 event_id, uint64_t ts_event, uint64_t ts_init)

Represents an event where a position has been opened.

Parameters:
  • trader_id (TraderId) – The trader ID.

  • strategy_id (StrategyId) – The strategy ID.

  • instrument_id (InstrumentId) – The instrument ID.

  • position_id (PositionId) – The position IDt.

  • account_id (AccountId) – The strategy ID.

  • opening_order_id (ClientOrderId) – The client order ID for the order which opened the position.

  • strategy_id – The strategy ID associated with the event.

  • entry (OrderSide {BUY, SELL}) – The position entry order side.

  • side (PositionSide {LONG, SHORT}) – The current position side.

  • signed_qty (double) – The current signed quantity (positive for LONG, negative for SHORT).

  • quantity (Quantity) – The current open quantity.

  • peak_qty (Quantity) – The peak directional quantity reached by the position.

  • last_qty (Quantity) – The last fill quantity for the position.

  • last_px (Price) – The last fill price for the position (not average price).

  • currency (Currency) – The position quote currency.

  • avg_px_open (double) – The average open price.

  • realized_pnl (Money) – The realized PnL for the position.

  • event_id (UUID4) – The event ID.

  • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the position opened event occurred.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

account_id

The account ID associated with the position.

Returns:

AccountId

avg_px_close

The average closing price.

Returns:

double

avg_px_open

The average open price.

Returns:

double

closing_order_id

The client order ID for the order which closed the position.

Returns:

ClientOrderId or None

static create(Position position, OrderFilled fill, UUID4 event_id, uint64_t ts_init)

Return a position opened event from the given params.

Parameters:
  • position (Position) – The position for the event.

  • fill (OrderFilled) – The order fill for the event.

  • event_id (UUID4) – The event ID.

  • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

PositionOpened

currency

The position quote currency.

Returns:

Currency

duration_ns

The total open duration (nanoseconds).

Returns:

uint64_t

entry

The entry direction from open.

Returns:

OrderSide

static from_dict(dict values) PositionOpened

Return a position opened event from the given dict values.

Parameters:

values (dict[str, object]) – The values for initialization.

Return type:

PositionOpened

id

UUID4

The event message identifier.

Return type:

UUID4

Type:

PositionEvent.id

instrument_id

The instrument ID associated with the event.

Returns:

InstrumentId

last_px

The last fill price for the position.

Returns:

Price

last_qty

The last fill quantity for the position.

Returns:

Quantity

opening_order_id

The client order ID for the order which opened the position.

Returns:

ClientOrderId

peak_qty

The peak directional quantity reached by the position.

Returns:

Quantity

position_id

The position ID associated with the event.

Returns:

PositionId

quantity

The position open quantity.

Returns:

Quantity

realized_pnl

The realized PnL for the position (including commissions).

Returns:

Money

realized_return

The realized return for the position.

Returns:

double

side

The position side.

Returns:

PositionSide

signed_qty

The position signed quantity (positive for LONG, negative for SHORT).

Returns:

double

strategy_id

The strategy ID associated with the event.

Returns:

StrategyId

static to_dict(PositionOpened obj)

Return a dictionary representation of this object.

Return type:

dict[str, object]

trader_id

The trader ID associated with the event.

Returns:

TraderId

ts_closed

UNIX timestamp (nanoseconds) when the position was closed.

Returns:

uint64_t

ts_event

int

UNIX timestamp (nanoseconds) when the event occurred.

Return type:

int

Type:

PositionEvent.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

Return type:

int

Type:

PositionEvent.ts_init

ts_opened

UNIX timestamp (nanoseconds) when the position was opened.

Returns:

uint64_t

unrealized_pnl

The unrealized PnL for the position (including commissions).

Returns:

Money