Events ¶
Defines the fundamental event types represented within the trading domain.
- class AccountState ( AccountId account_id , AccountType account_type , Currency base_currency , bool reported , list balances , list margins , dict info , UUID4 event_id , uint64_t ts_event , uint64_t ts_init ) ¶
-
Bases:
Event
Represents an event which includes information on the state of the account.
- Parameters :
-
-
account_id ( AccountId ) – The account ID (with the venue).
-
account_type ( AccountId ) – 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 ) – The UNIX timestamp (nanoseconds) when the account state event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
AccountState
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
AccountState.id
- info ¶
-
The additional implementation specific account information.
- Returns :
-
dict[str, object]
- is_reported ¶
-
If the state is reported from the exchange (otherwise system calculated).
- Returns :
-
bool
- margins ¶
-
The margin balances.
- Returns :
-
list[MarginBalance]
- static to_dict ( AccountState obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
AccountState.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
AccountState.ts_init
- class OrderAccepted ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , VenueOrderId venue_order_id , AccountId account_id , UUID4 event_id , uint64_t ts_event , uint64_t ts_init , bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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 trade 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 ) – The UNIX timestamp (nanoseconds) when the order accepted event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
reconciliation ( bool , default False ) – If the event was generated during reconciliation.
-
References
https://www.onixs.biz/fix-dictionary/5.0.SP2/tagNum_39.html
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderAccepted.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderAccepted.client_order_id
- static from_dict ( dict values ) OrderAccepted ¶
-
Return an order accepted event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderAccepted
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderAccepted.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderAccepted.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderAccepted.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderAccepted.strategy_id
- static to_dict ( OrderAccepted obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderAccepted.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderAccepted.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderAccepted.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderAccepted.venue_order_id
- class OrderCancelRejected ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: Optional[VenueOrderId], AccountId account_id: Optional[AccountId], unicode reason, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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, optional with no default so
None
must be passed explicitly) – The venue order ID (assigned by the venue). -
account_id (AccountId, optional with no default so
None
must be passed explicitly) – The account ID (with the venue). -
reason ( str ) – The order cancel rejected reason.
-
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the order cancel rejected event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
reconciliation ( bool , default False ) – If the event was generated during reconciliation.
-
- Raises :
-
ValueError – If reason is not a valid string.
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderCancelRejected.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderCancelRejected.client_order_id
- static from_dict ( dict values ) OrderCancelRejected ¶
-
Return an order cancel rejected event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderCancelRejected
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderCancelRejected.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderCancelRejected.instrument_id
- reason ¶
-
str
Return the reason the order was rejected.
- Returns :
-
str
- Type :
-
OrderCancelRejected.reason
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderCancelRejected.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderCancelRejected.strategy_id
- static to_dict ( OrderCancelRejected obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderCancelRejected.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderCancelRejected.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderCancelRejected.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderCancelRejected.venue_order_id
- class OrderCanceled ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: Optional[VenueOrderId], AccountId account_id: Optional[AccountId], UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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, optional with no default so
None
must be passed explicitly) – The venue order ID (assigned by the venue). -
account_id (AccountId, optional with no default so
None
must be passed explicitly) – The account ID (with the venue). -
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when order canceled event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
AccountId or None
- Type :
-
OrderCanceled.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderCanceled.client_order_id
- static from_dict ( dict values ) OrderCanceled ¶
-
Return an order canceled event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderCanceled
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderCanceled.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderCanceled.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderCanceled.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderCanceled.strategy_id
- static to_dict ( OrderCanceled obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderCanceled.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderCanceled.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderCanceled.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderCanceled.venue_order_id
- class OrderDenied ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , unicode reason , UUID4 event_id , uint64_t ts_init ) ¶
-
Bases:
OrderEvent
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 ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
- Raises :
-
ValueError – If denied_reason is not a valid_string.
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderDenied.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderDenied.client_order_id
- static from_dict ( dict values ) OrderDenied ¶
-
Return an order denied event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderDenied
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderDenied.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderDenied.instrument_id
- reason ¶
-
str
Return the reason the order was denied.
- Returns :
-
str
- Type :
-
OrderDenied.reason
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderDenied.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderDenied.strategy_id
- static to_dict ( OrderDenied obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderDenied.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderDenied.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderDenied.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderDenied.venue_order_id
- class OrderEmulated ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , UUID4 event_id , uint64_t ts_init ) ¶
-
Bases:
OrderEvent
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 ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderEmulated.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderEmulated.client_order_id
- static from_dict ( dict values ) OrderEmulated ¶
-
Return an order emulated event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderEmulated
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderEmulated.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderEmulated.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderEmulated.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderEmulated.strategy_id
- static to_dict ( OrderEmulated obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderEmulated.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderEmulated.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderEmulated.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderEmulated.venue_order_id
- class OrderEvent ¶
-
Bases:
Event
The abstract base class for all order events.
Warning
This class should not be used directly, but through a concrete subclass.
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderEvent.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderEvent.client_order_id
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderEvent.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderEvent.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderEvent.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderEvent.strategy_id
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderEvent.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderEvent.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderEvent.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderEvent.venue_order_id
- class OrderExpired ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: Optional[VenueOrderId], AccountId account_id: Optional[AccountId], UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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, optional with no default so
None
must be passed explicitly) – The venue order ID (assigned by the venue). -
account_id (AccountId, optional with no default so
None
must be passed explicitly) – The account ID (with the venue). -
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the order expired event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
AccountId or None
- Type :
-
OrderExpired.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderExpired.client_order_id
- static from_dict ( dict values ) OrderExpired ¶
-
Return an order expired event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderExpired
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderExpired.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderExpired.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderExpired.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderExpired.strategy_id
- static to_dict ( OrderExpired obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderExpired.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderExpired.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderExpired.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderExpired.venue_order_id
- class OrderFilled ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id, AccountId account_id, TradeId trade_id, PositionId position_id: Optional[PositionId], 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 ) ¶
-
Bases:
OrderEvent
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, optional with no default so
None
must be passed explicitly) – The position ID associated with the order fill (assigned by the venue). -
order_side ( OrderType ) – The execution order side.
-
order_side – 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 ) – The UNIX timestamp (nanoseconds) when the order filled event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
AccountId or None
- Type :
-
OrderFilled.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderFilled.client_order_id
- commission ¶
-
The commission generated from the fill.
- Returns :
-
Money
- currency ¶
-
The currency of the price.
- Returns :
-
Currency
- static from_dict ( dict values ) OrderFilled ¶
-
Return an order filled event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderFilled
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderFilled.id
- info ¶
-
The additional fill information.
- Returns :
-
dict[str, object]
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderFilled.instrument_id
- is_buy ¶
-
Return whether the fill order side is
BUY
.- Returns :
-
bool
- is_sell ¶
-
Return whether the fill order side is
SELL
.- Returns :
-
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.
- Returns :
-
bool
- Type :
-
OrderFilled.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderFilled.strategy_id
- static to_dict ( OrderFilled obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
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.
- Returns :
-
TraderId
- Type :
-
OrderFilled.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderFilled.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderFilled.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderFilled.venue_order_id
- class OrderInitialized ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, OrderType order_type, Quantity quantity, TimeInForce time_in_force, bool post_only, bool reduce_only, bool quote_quantity, dict options, TriggerType emulation_trigger, InstrumentId trigger_instrument_id: Optional[InstrumentId], ContingencyType contingency_type, OrderListId order_list_id: Optional[OrderListId], list linked_order_ids: Optional[list[ClientOrderId]], ClientOrderId parent_order_id: Optional[ClientOrderId], ExecAlgorithmId exec_algorithm_id: Optional[ExecAlgorithmId], dict exec_algorithm_params: Optional[dict[str, Any]], ClientOrderId exec_spawn_id: Optional[ClientOrderId], unicode tags: Optional[str], UUID4 event_id, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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 ( EmulationTrigger ) – The emulation trigger for the order.
-
trigger_instrument_id (InstrumentId, optional with no default so
None
must be passed explicitly) – The emulation trigger instrument ID for the order (ifNone
then will be the instrument_id ). -
contingency_type ( ContingencyType ) – The order contingency type.
-
order_list_id (OrderListId, optional with no default so
None
must be passed explicitly) – The order list ID associated with the order. -
linked_order_ids (list[ClientOrderId], optional with no default so
None
must be passed explicitly) – The order linked client order ID(s). -
parent_order_id (ClientOrderId, optional with no default so
None
must be passed explicitly) – The orders parent client order ID. -
exec_algorithm_id (ExecAlgorithmId, optional with no default so
None
must be passed explicitly) – 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, optional with no default so
None
must be passed explicitly) – The execution algorithm spawning primary client order ID. -
tags (str, optional with no default so
None
must be passed explicitly) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required. -
event_id ( UUID4 ) – The event ID.
-
ts_init ( uint64_t ) – The 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 exec_algorithm_id is not
None
, and exec_spawn_id isNone
.
-
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderInitialized.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderInitialized.client_order_id
- contingency_type ¶
-
The orders contingency type.
- Returns :
-
ContingencyType
- emulation_trigger ¶
-
The order emulation trigger type.
- Returns :
-
TriggerType
- exec_algorithm_id ¶
-
The execution algorithm ID for the order.
- Returns :
-
ExecAlgorithmId or
None
- exec_algorithm_params ¶
-
The execution algorithm parameters for the order.
- Returns :
-
dict[str, Any] or
None
- exec_spawn_id ¶
-
The execution algorithm spawning client order ID.
- Returns :
-
ClientOrderId or
None
- static from_dict ( dict values ) OrderInitialized ¶
-
Return an order initialized event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderInitialized
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderInitialized.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderInitialized.instrument_id
- linked_order_ids ¶
-
The orders linked client order ID(s).
- Returns :
-
list[ClientOrderId] or
None
- options ¶
-
The order initialization options.
- Returns :
-
dict
- order_list_id ¶
-
The order list ID associated with the order.
- Returns :
-
OrderListId or
None
- order_type ¶
-
The order type.
- Returns :
-
OrderType
- parent_order_id ¶
-
The orders parent client order ID.
- Returns :
-
ClientOrderId or
None
- post_only ¶
-
If the order will only provide liquidity (make a market).
- Returns :
-
bool
- quantity ¶
-
The order quantity.
- Returns :
-
Quantity
- quote_quantity ¶
-
If the order quantity is denominated in the quote currency.
- Returns :
-
bool
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderInitialized.reconciliation
- reduce_only ¶
-
If the order carries the ‘reduce-only’ execution instruction.
- Returns :
-
bool
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- side ¶
-
The order side.
- Returns :
-
OrderSide
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderInitialized.strategy_id
- tags ¶
-
The order custom user tags.
- Returns :
-
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.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderInitialized.trader_id
- trigger_instrument_id ¶
-
The order emulation trigger instrument ID (will be instrument_id if
None
).- Returns :
-
InstrumentId or
None
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderInitialized.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderInitialized.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderInitialized.venue_order_id
- class OrderModifyRejected ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: Optional[VenueOrderId], AccountId account_id: Optional[AccountId], unicode reason, UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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, optional with no default so
None
must be passed explicitly) – The venue order ID (assigned by the venue). -
account_id (AccountId, optional with no default so
None
must be passed explicitly) – The account ID (with the venue). -
reason ( str ) – The order update rejected reason.
-
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the order update rejected event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
reconciliation ( bool , default False ) – If the event was generated during reconciliation.
-
- Raises :
-
ValueError – If reason is not a valid string.
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderModifyRejected.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderModifyRejected.client_order_id
- static from_dict ( dict values ) OrderModifyRejected ¶
-
Return an order update rejected event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderModifyRejected
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderModifyRejected.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderModifyRejected.instrument_id
- reason ¶
-
str
Return the reason the order was rejected.
- Returns :
-
str
- Type :
-
OrderModifyRejected.reason
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderModifyRejected.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderModifyRejected.strategy_id
- static to_dict ( OrderModifyRejected obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderModifyRejected.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderModifyRejected.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderModifyRejected.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderModifyRejected.venue_order_id
- class OrderPendingCancel ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: Optional[VenueOrderId], AccountId account_id: Optional[AccountId], UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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, optional with no default so
None
must be passed explicitly) – The venue order ID (assigned by the venue). -
account_id (AccountId, optional with no default so
None
must be passed explicitly) – The account ID (with the venue). -
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the order pending cancel event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
AccountId or None
- Type :
-
OrderPendingCancel.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderPendingCancel.client_order_id
- static from_dict ( dict values ) OrderPendingCancel ¶
-
Return an order pending cancel event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderPendingCancel
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderPendingCancel.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderPendingCancel.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderPendingCancel.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderPendingCancel.strategy_id
- static to_dict ( OrderPendingCancel obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderPendingCancel.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderPendingCancel.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderPendingCancel.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderPendingCancel.venue_order_id
- class OrderPendingUpdate ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: Optional[VenueOrderId], AccountId account_id: Optional[AccountId], UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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, optional with no default so
None
must be passed explicitly) – The venue order ID (assigned by the venue). -
account_id (AccountId, optional with no default so
None
must be passed explicitly) – The account ID (with the venue). -
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the order pending update event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
AccountId or None
- Type :
-
OrderPendingUpdate.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderPendingUpdate.client_order_id
- static from_dict ( dict values ) OrderPendingUpdate ¶
-
Return an order pending update event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderPendingUpdate
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderPendingUpdate.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderPendingUpdate.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderPendingUpdate.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderPendingUpdate.strategy_id
- static to_dict ( OrderPendingUpdate obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderPendingUpdate.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderPendingUpdate.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderPendingUpdate.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderPendingUpdate.venue_order_id
- class OrderRejected ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , AccountId account_id , unicode reason , UUID4 event_id , uint64_t ts_event , uint64_t ts_init , bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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 ( datetime ) – The order rejected reason.
-
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the order rejected event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
reconciliation ( bool , default False ) – If the event was generated during reconciliation.
-
- Raises :
-
ValueError – If reason is not a valid string.
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderRejected.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderRejected.client_order_id
- 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.
- Returns :
-
OrderRejected
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderRejected.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderRejected.instrument_id
- reason ¶
-
str
Return the reason the order was rejected.
- Returns :
-
str
- Type :
-
OrderRejected.reason
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderRejected.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderRejected.strategy_id
- static to_dict ( OrderRejected obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderRejected.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderRejected.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderRejected.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderRejected.venue_order_id
- class OrderReleased ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , Price released_price , UUID4 event_id , uint64_t ts_init ) ¶
-
Bases:
OrderEvent
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 ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderReleased.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderReleased.client_order_id
- static from_dict ( dict values ) OrderReleased ¶
-
Return an order released event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderReleased
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderReleased.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderReleased.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderReleased.reconciliation
- released_price ¶
-
Price
The released price for the event.
- Returns :
-
Price
- Type :
-
OrderReleased.released_price
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderReleased.strategy_id
- static to_dict ( OrderReleased obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderReleased.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderReleased.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderReleased.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderReleased.venue_order_id
- class OrderSubmitted ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , AccountId account_id , UUID4 event_id , uint64_t ts_event , uint64_t ts_init ) ¶
-
Bases:
OrderEvent
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 ) – The UNIX timestamp (nanoseconds) when the order submitted event occurred.
-
ts_init ( uint64_t ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
- account_id ¶
-
AccountId | None
The account ID associated with the event.
- Returns :
-
AccountId or None
- Type :
-
OrderSubmitted.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderSubmitted.client_order_id
- static from_dict ( dict values ) OrderSubmitted ¶
-
Return an order submitted event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderSubmitted
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderSubmitted.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderSubmitted.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderSubmitted.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderSubmitted.strategy_id
- static to_dict ( OrderSubmitted obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderSubmitted.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderSubmitted.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderSubmitted.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderSubmitted.venue_order_id
- class OrderTriggered ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: Optional[VenueOrderId], AccountId account_id: Optional[AccountId], UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
Represents an event where an order has triggered.
Applicable to
StopLimit
orders only.- Parameters :
-
-
trader_id ( TraderId ) – The trader ID.
-
strategy_id ( StrategyId ) – The strategy ID.
-
instrument_id ( InstrumentId ) – The instrument ID.
-
client_order_id ( ClientOrderId ) – The client order ID.
-
venue_order_id (VenueOrderId, optional with no default so
None
must be passed explicitly) – The venue order ID (assigned by the venue). -
account_id (AccountId, optional with no default so
None
must be passed explicitly) – The account ID (with the venue). -
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the order triggered event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
AccountId or None
- Type :
-
OrderTriggered.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderTriggered.client_order_id
- static from_dict ( dict values ) OrderTriggered ¶
-
Return an order triggered event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderTriggered
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderTriggered.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderTriggered.instrument_id
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderTriggered.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderTriggered.strategy_id
- static to_dict ( OrderTriggered obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderTriggered.trader_id
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderTriggered.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderTriggered.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderTriggered.venue_order_id
- class OrderUpdated ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, VenueOrderId venue_order_id: Optional[VenueOrderId], AccountId account_id: Optional[AccountId], Quantity quantity, Price price: Optional[Price], Price trigger_price: Optional[Price], UUID4 event_id, uint64_t ts_event, uint64_t ts_init, bool reconciliation=False ) ¶
-
Bases:
OrderEvent
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, optional with no default so
None
must be passed explicitly) – The venue order ID (assigned by the venue). -
account_id (AccountId, optional with no default so
None
must be passed explicitly) – The account ID (with the venue). -
quantity ( Quantity ) – The orders current quantity.
-
price (Price, optional with no default so
None
must be passed explicitly) – The orders current price. -
trigger_price (Price, optional with no default so
None
must be passed explicitly) – The orders current trigger. -
event_id ( UUID4 ) – The event ID.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the order updated event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
AccountId or None
- Type :
-
OrderUpdated.account_id
- client_order_id ¶
-
ClientOrderId
The client order ID associated with the event.
- Returns :
-
ClientOrderId
- Type :
-
OrderUpdated.client_order_id
- static from_dict ( dict values ) OrderUpdated ¶
-
Return an order updated event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
OrderUpdated
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
OrderUpdated.id
- instrument_id ¶
-
InstrumentId
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- Type :
-
OrderUpdated.instrument_id
- price ¶
-
The orders current price.
- Returns :
-
Price
- quantity ¶
-
The orders current quantity.
- Returns :
-
Quantity
- reconciliation ¶
-
bool
If the event was generated during reconciliation.
- Returns :
-
bool
- Type :
-
OrderUpdated.reconciliation
- set_client_order_id ( self , ClientOrderId client_order_id ) ¶
- strategy_id ¶
-
TraderId
The strategy ID associated with the event.
- Returns :
-
StrategyId
- Type :
-
OrderUpdated.strategy_id
- static to_dict ( OrderUpdated obj ) ¶
-
Return a dictionary representation of this object.
- Returns :
-
dict[str, object]
- trader_id ¶
-
TraderId
The trader ID associated with the event.
- Returns :
-
TraderId
- Type :
-
OrderUpdated.trader_id
- trigger_price ¶
-
The orders current trigger price.
- Returns :
-
Price or
None
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
OrderUpdated.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
OrderUpdated.ts_init
- venue_order_id ¶
-
VenueOrderId | None
The venue order ID associated with the event.
- Returns :
-
VenueOrderId or None
- Type :
-
OrderUpdated.venue_order_id
- class PositionChanged ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , PositionId position_id , AccountId account_id , ClientOrderId opening_order_id , OrderSide entry , PositionSide side , double signed_qty , Quantity quantity , Quantity peak_qty , Quantity last_qty , Price last_px , Currency currency , double avg_px_open , double avg_px_close , double realized_return , Money realized_pnl , Money unrealized_pnl , UUID4 event_id , uint64_t ts_opened , uint64_t ts_event , uint64_t ts_init ) ¶
-
Bases:
PositionEvent
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 ( Decimal ) – The average open price.
-
avg_px_close ( Decimal , optional ) – The average close price.
-
realized_return ( Decimal ) – 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 ) – The UNIX timestamp (nanoseconds) when the position opened event occurred.
-
ts_event ( uint64_t ) – The UNIX timestamp (nanoseconds) when the position changed event occurred.
-
ts_init ( uint64_t ) – The 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 ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
- Returns :
-
PositionChanged
- currency ¶
-
The position quote currency.
- Returns :
-
Currency
- duration_ns ¶
-
The total open duration (nanoseconds).
- Returns :
-
uint64_t
- entry ¶
-
The entry direction from open.
- Returns :
-
OrderSide
- static from_dict ( dict values ) PositionChanged ¶
-
Return a position changed event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
PositionChanged
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
PositionEvent.id
- instrument_id ¶
-
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- last_px ¶
-
The last fill price for the position.
- Returns :
-
Price
- last_qty ¶
-
The last fill quantity for the position.
- Returns :
-
Quantity
- opening_order_id ¶
-
The client order ID for the order which opened the position.
- Returns :
-
ClientOrderId
- peak_qty ¶
-
The peak directional quantity reached by the position.
- Returns :
-
Quantity
- position_id ¶
-
The position ID associated with the event.
- Returns :
-
PositionId
- quantity ¶
-
The position open quantity.
- Returns :
-
Quantity
- realized_pnl ¶
-
The realized PnL for the position (including commissions).
- Returns :
-
Money
- realized_return ¶
-
The realized return for the position.
- Returns :
-
double
- side ¶
-
The position side.
- Returns :
-
PositionSide
- signed_qty ¶
-
The position signed quantity (positive for
LONG
, negative 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.
- Returns :
-
dict[str, object]
- trader_id ¶
-
The trader ID associated with the event.
- Returns :
-
TraderId
- ts_closed ¶
-
The UNIX timestamp (nanoseconds) when the position was closed.
- Returns :
-
uint64_t
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
PositionEvent.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
PositionEvent.ts_init
- ts_opened ¶
-
The 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 ( 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 ) ¶
-
Bases:
PositionEvent
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 ) – The UNIX timestamp (nanoseconds) when the position opened event occurred.
-
ts_closed ( uint64_t ) – The UNIX timestamp (nanoseconds) when the position closed event occurred.
-
duration_ns ( uint64_t ) – The total open duration (nanoseconds).
-
ts_init ( uint64_t ) – The 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 ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
- Returns :
-
PositionClosed
- currency ¶
-
The position quote currency.
- Returns :
-
Currency
- duration_ns ¶
-
The total open duration (nanoseconds).
- Returns :
-
uint64_t
- entry ¶
-
The entry direction from open.
- Returns :
-
OrderSide
- static from_dict ( dict values ) PositionClosed ¶
-
Return a position closed event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
PositionClosed
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
PositionEvent.id
- instrument_id ¶
-
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- last_px ¶
-
The last fill price for the position.
- Returns :
-
Price
- last_qty ¶
-
The last fill quantity for the position.
- Returns :
-
Quantity
- opening_order_id ¶
-
The client order ID for the order which opened the position.
- Returns :
-
ClientOrderId
- peak_qty ¶
-
The peak directional quantity reached by the position.
- Returns :
-
Quantity
- position_id ¶
-
The position ID associated with the event.
- Returns :
-
PositionId
- quantity ¶
-
The position open quantity.
- Returns :
-
Quantity
- realized_pnl ¶
-
The realized PnL for the position (including commissions).
- Returns :
-
Money
- realized_return ¶
-
The realized return for the position.
- Returns :
-
double
- side ¶
-
The position side.
- Returns :
-
PositionSide
- signed_qty ¶
-
The position signed quantity (positive for
LONG
, negative 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.
- Returns :
-
dict[str, object]
- trader_id ¶
-
The trader ID associated with the event.
- Returns :
-
TraderId
- ts_closed ¶
-
The UNIX timestamp (nanoseconds) when the position was closed.
- Returns :
-
uint64_t
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
PositionEvent.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
PositionEvent.ts_init
- ts_opened ¶
-
The 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 ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, PositionId position_id, AccountId account_id, ClientOrderId opening_order_id, ClientOrderId closing_order_id: Optional[ClientOrderId], 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 ) ¶
-
Bases:
Event
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 ) – The UNIX timestamp (nanoseconds) when the position opened event occurred.
-
ts_closed ( uint64_t ) – The 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 ) – The UNIX timestamp (nanoseconds) when the event occurred.
-
ts_init ( uint64_t ) – The 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.
- Returns :
-
UUID4
- Type :
-
PositionEvent.id
- instrument_id ¶
-
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- last_px ¶
-
The last fill price for the position.
- Returns :
-
Price
- last_qty ¶
-
The last fill quantity for the position.
- Returns :
-
Quantity
- opening_order_id ¶
-
The client order ID for the order which opened the position.
- Returns :
-
ClientOrderId
- peak_qty ¶
-
The peak directional quantity reached by the position.
- Returns :
-
Quantity
- position_id ¶
-
The position ID associated with the event.
- Returns :
-
PositionId
- quantity ¶
-
The position open quantity.
- Returns :
-
Quantity
- realized_pnl ¶
-
The realized PnL for the position (including commissions).
- Returns :
-
Money
- realized_return ¶
-
The realized return for the position.
- Returns :
-
double
- side ¶
-
The position side.
- Returns :
-
PositionSide
- signed_qty ¶
-
The position signed quantity (positive for
LONG
, negative 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 ¶
-
The UNIX timestamp (nanoseconds) when the position was closed.
- Returns :
-
uint64_t
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
PositionEvent.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
PositionEvent.ts_init
- ts_opened ¶
-
The 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 ( 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 ) ¶
-
Bases:
PositionEvent
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 ) – The UNIX timestamp (nanoseconds) when the position opened event occurred.
-
ts_init ( uint64_t ) – The 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 ) – The UNIX timestamp (nanoseconds) when the object was initialized.
-
- Returns :
-
PositionOpened
- currency ¶
-
The position quote currency.
- Returns :
-
Currency
- duration_ns ¶
-
The total open duration (nanoseconds).
- Returns :
-
uint64_t
- entry ¶
-
The entry direction from open.
- Returns :
-
OrderSide
- static from_dict ( dict values ) PositionOpened ¶
-
Return a position opened event from the given dict values.
- Parameters :
-
values ( dict [ str , object ] ) – The values for initialization.
- Returns :
-
PositionOpened
- id ¶
-
UUID4
The event message identifier.
- Returns :
-
UUID4
- Type :
-
PositionEvent.id
- instrument_id ¶
-
The instrument ID associated with the event.
- Returns :
-
InstrumentId
- last_px ¶
-
The last fill price for the position.
- Returns :
-
Price
- last_qty ¶
-
The last fill quantity for the position.
- Returns :
-
Quantity
- opening_order_id ¶
-
The client order ID for the order which opened the position.
- Returns :
-
ClientOrderId
- peak_qty ¶
-
The peak directional quantity reached by the position.
- Returns :
-
Quantity
- position_id ¶
-
The position ID associated with the event.
- Returns :
-
PositionId
- quantity ¶
-
The position open quantity.
- Returns :
-
Quantity
- realized_pnl ¶
-
The realized PnL for the position (including commissions).
- Returns :
-
Money
- realized_return ¶
-
The realized return for the position.
- Returns :
-
double
- side ¶
-
The position side.
- Returns :
-
PositionSide
- signed_qty ¶
-
The position signed quantity (positive for
LONG
, negative 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.
- Returns :
-
dict[str, object]
- trader_id ¶
-
The trader ID associated with the event.
- Returns :
-
TraderId
- ts_closed ¶
-
The UNIX timestamp (nanoseconds) when the position was closed.
- Returns :
-
uint64_t
- ts_event ¶
-
int
The UNIX timestamp (nanoseconds) when the event occurred.
- Returns :
-
int
- Type :
-
PositionEvent.ts_event
- ts_init ¶
-
int
The UNIX timestamp (nanoseconds) when the object was initialized.
- Returns :
-
int
- Type :
-
PositionEvent.ts_init
- ts_opened ¶
-
The UNIX timestamp (nanoseconds) when the position was opened.
- Returns :
-
uint64_t
- unrealized_pnl ¶
-
The unrealized PnL for the position (including commissions).
- Returns :
-
Money