Events¶
Defines the fundamental event types represented within the trading domain.
- class AccountState¶
Bases:
EventAccountState(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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- class OrderAccepted¶
Bases:
OrderEventOrderAccepted(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderCancelRejected¶
Bases:
OrderEventOrderCancelRejected(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reason¶
str
Return the reason the order was rejected.
- Return type:
str
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderCanceled¶
Bases:
OrderEventOrderCanceled(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderDenied¶
Bases:
OrderEventOrderDenied(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reason¶
str
Return the reason the order was denied.
- Return type:
str
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderEmulated¶
Bases:
OrderEventOrderEmulated(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderEvent¶
Bases:
EventThe 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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- trader_id¶
TraderId
The trader ID associated with the event.
- Return type:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderExpired¶
Bases:
OrderEventOrderExpired(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderFilled¶
Bases:
OrderEventOrderFilled(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- info¶
The additional fill information.
- Returns:
dict[str, object]
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- 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:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderInitialized¶
Bases:
OrderEventOrderInitialized(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 asBID_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 (ifNonethen 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 isNoneor empty.ValueError – If exec_algorithm_id is not
None, and exec_spawn_id isNone.
- account_id¶
AccountId | None
The account ID associated with the event.
- Return type:
AccountId or
None- Type:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- 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:
- 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:
- Type:
- 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:
- Type:
- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderModifyRejected¶
Bases:
OrderEventOrderModifyRejected(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reason¶
str
Return the reason the order was rejected.
- Return type:
str
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderPendingCancel¶
Bases:
OrderEventOrderPendingCancel(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderPendingUpdate¶
Bases:
OrderEventOrderPendingUpdate(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderRejected¶
Bases:
OrderEventOrderRejected(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reason¶
str
Return the reason the order was rejected.
- Return type:
str
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderReleased¶
Bases:
OrderEventOrderReleased(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- released_price¶
Price
The released price for the event.
- Return type:
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderSubmitted¶
Bases:
OrderEventOrderSubmitted(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderTriggered¶
Bases:
OrderEventOrderTriggered(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
StopLimitorders 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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderUpdated¶
Bases:
OrderEventOrderUpdated(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- 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:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class PositionAdjusted¶
Bases:
EventPositionAdjusted(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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- class PositionChanged¶
Bases:
PositionEventPositionChanged(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 forSHORT).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:
- 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:
- static to_dict(PositionChanged obj)¶
Return a dictionary representation of this object.
- Return type:
dict[str, object]
- class PositionClosed¶
Bases:
PositionEventPositionClosed(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 forSHORT).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:
- 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:
- static to_dict(PositionClosed obj)¶
Return a dictionary representation of this object.
- Return type:
dict[str, object]
- class PositionEvent¶
Bases:
EventPositionEvent(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 forSHORT).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:
- Type:
- 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 forSHORT).- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- 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:
PositionEventPositionOpened(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 forSHORT).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:
- 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:
- static to_dict(PositionOpened obj)¶
Return a dictionary representation of this object.
- Return type:
dict[str, object]
- class AccountState¶
Bases:
EventAccountState(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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- class OrderAccepted¶
Bases:
OrderEventOrderAccepted(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderCancelRejected¶
Bases:
OrderEventOrderCancelRejected(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reason¶
str
Return the reason the order was rejected.
- Return type:
str
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderCanceled¶
Bases:
OrderEventOrderCanceled(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderDenied¶
Bases:
OrderEventOrderDenied(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reason¶
str
Return the reason the order was denied.
- Return type:
str
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderEmulated¶
Bases:
OrderEventOrderEmulated(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderEvent¶
Bases:
EventThe 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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- trader_id¶
TraderId
The trader ID associated with the event.
- Return type:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderExpired¶
Bases:
OrderEventOrderExpired(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderFilled¶
Bases:
OrderEventOrderFilled(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- info¶
The additional fill information.
- Returns:
dict[str, object]
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- 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:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderInitialized¶
Bases:
OrderEventOrderInitialized(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 asBID_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 (ifNonethen 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 isNoneor empty.ValueError – If exec_algorithm_id is not
None, and exec_spawn_id isNone.
- account_id¶
AccountId | None
The account ID associated with the event.
- Return type:
AccountId or
None- Type:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- 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:
- 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:
- Type:
- 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:
- Type:
- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderModifyRejected¶
Bases:
OrderEventOrderModifyRejected(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reason¶
str
Return the reason the order was rejected.
- Return type:
str
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderPendingCancel¶
Bases:
OrderEventOrderPendingCancel(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderPendingUpdate¶
Bases:
OrderEventOrderPendingUpdate(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderRejected¶
Bases:
OrderEventOrderRejected(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reason¶
str
Return the reason the order was rejected.
- Return type:
str
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderReleased¶
Bases:
OrderEventOrderReleased(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- released_price¶
Price
The released price for the event.
- Return type:
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderSubmitted¶
Bases:
OrderEventOrderSubmitted(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderTriggered¶
Bases:
OrderEventOrderTriggered(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
StopLimitorders 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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- reconciliation¶
bool
If the event was generated during reconciliation.
- Return type:
bool
- Type:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- ts_event¶
int
UNIX timestamp (nanoseconds) when the event occurred.
- Return type:
int
- Type:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class OrderUpdated¶
Bases:
OrderEventOrderUpdated(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:
- client_order_id¶
ClientOrderId
The client order ID associated with the event.
- Return type:
- Type:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- instrument_id¶
InstrumentId
The instrument ID associated with the event.
- Return type:
- Type:
- 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:
- set_client_order_id(self, ClientOrderId client_order_id)¶
- strategy_id¶
TraderId
The strategy ID associated with the event.
- Return type:
- Type:
- 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:
- Type:
- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- venue_order_id¶
VenueOrderId | None
The venue order ID associated with the event.
- Return type:
VenueOrderId or
None- Type:
- class PositionAdjusted¶
Bases:
EventPositionAdjusted(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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- class PositionChanged¶
Bases:
PositionEventPositionChanged(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 forSHORT).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:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- 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 forSHORT).- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- 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:
PositionEventPositionClosed(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 forSHORT).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:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- 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 forSHORT).- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- 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:
EventPositionEvent(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 forSHORT).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:
- Type:
- 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 forSHORT).- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- 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:
PositionEventPositionOpened(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 forSHORT).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:
- 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:
- id¶
UUID4
The event message identifier.
- Return type:
- Type:
- 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 forSHORT).- 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:
- ts_init¶
int
UNIX timestamp (nanoseconds) when the object was initialized.
- Return type:
int
- Type:
- 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