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