Orders

The platform offers a full range of standard order types, as well as bulk order lists.

Market

class MarketOrder ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , OrderSide order_side , Quantity quantity , UUID4 init_id , uint64_t ts_init , TimeInForce time_in_force=TimeInForce.GTC , bool reduce_only=False , OrderListId order_list_id=None , ContingencyType contingency_type=ContingencyType.NONE , list linked_order_ids=None , ClientOrderId parent_order_id=None , unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Market order.

  • A Market-On-Open (MOO) order can be represented using a time in force of AT_THE_OPEN .

  • A Market-On-Close (MOC) order can be represented using a time in force of AT_THE_CLOSE .

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

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

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If time_in_force is GTD .

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Limit

class LimitOrder ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , OrderSide order_side , Quantity quantity , Price price , UUID4 init_id , uint64_t ts_init , TimeInForce time_in_force=TimeInForce.GTC , uint64_t expire_time_ns=0 , bool post_only=False , bool reduce_only=False , Quantity display_qty=None , OrderListId order_list_id=None , ContingencyType contingency_type=ContingencyType.NONE , list linked_order_ids=None , ClientOrderId parent_order_id=None , unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Limit order.

  • A Limit-On-Open (LOO) order can be represented using a time in force of AT_THE_OPEN .

  • A Limit-On-Close (LOC) order can be represented using a time in force of AT_THE_CLOSE .

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • price ( Price ) – The order limit price.

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

  • expire_time_ns ( uint64_t , default 0 ( no expiry ) ) – The UNIX timestamp (nanoseconds) when the order will expire.

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

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

  • display_qty ( Quantity , optional ) – The quantity of the order to display on the public book (iceberg).

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.

  • ValueError – If display_qty is negative (< 0) or greater than quantity .

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

display_qty

The quantity of the order to display on the public book (iceberg).

Returns

Quantity or None

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

expire_time

Return the expire time for the order (UTC).

Returns

datetime or None

expire_time_ns

The order expiration (UNIX epoch nanoseconds), zero for no expiration.

Returns

uint64_t

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

price

The order price (LIMIT).

Returns

Price

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Stop-Market

class StopMarketOrder ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , OrderSide order_side , Quantity quantity , Price trigger_price , TriggerType trigger_type , UUID4 init_id , uint64_t ts_init , TimeInForce time_in_force=TimeInForce.GTC , uint64_t expire_time_ns=0 , bool reduce_only=False , OrderListId order_list_id=None , ContingencyType contingency_type=ContingencyType.NONE , list linked_order_ids=None , ClientOrderId parent_order_id=None , unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Stop-Market conditional order.

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • trigger_price ( Price ) – The order trigger price (STOP).

  • trigger_type ( TriggerType ) – The order trigger type.

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

  • expire_time_ns ( uint64_t , default 0 ( no expiry ) ) – The UNIX timestamp (nanoseconds) when the order will expire.

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

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If trigger_type is NONE .

  • ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE .

  • ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

expire_time

Return the expire time for the order (UTC).

Returns

datetime or None

expire_time_ns

The order expiration (UNIX epoch nanoseconds), zero for no expiration.

Returns

uint64_t

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

trigger_price

The order trigger price (STOP).

Returns

Price

trigger_type

The trigger type for the order.

Returns

TriggerType

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Stop-Limit

class StopLimitOrder ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , OrderSide order_side , Quantity quantity , Price price , Price trigger_price , TriggerType trigger_type , UUID4 init_id , uint64_t ts_init , TimeInForce time_in_force=TimeInForce.GTC , uint64_t expire_time_ns=0 , bool post_only=False , bool reduce_only=False , Quantity display_qty=None , OrderListId order_list_id=None , ContingencyType contingency_type=ContingencyType.NONE , list linked_order_ids=None , ClientOrderId parent_order_id=None , unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Stop-Limit conditional order.

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • price ( Price ) – The order price (LIMIT).

  • trigger_price ( Price ) – The order trigger price (STOP).

  • trigger_type ( TriggerType ) – The order trigger type.

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

  • expire_time_ns ( uint64_t , default 0 ( no expiry ) ) – The UNIX timestamp (nanoseconds) when the order will expire.

  • post_only ( bool , default False ) – If the LIMIT order will only provide liquidity (once triggered).

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

  • display_qty ( Quantity , optional ) – The quantity of the LIMIT order to display on the public book (iceberg).

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If trigger_type is NONE .

  • ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE .

  • ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.

  • ValueError – If display_qty is negative (< 0) or greater than quantity .

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

display_qty

The quantity of the LIMIT order to display on the public book (iceberg).

Returns

Quantity or None

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

expire_time

Return the expire time for the order (UTC).

Returns

datetime or None

expire_time_ns

The order expiration (UNIX epoch nanoseconds), zero for no expiration.

Returns

uint64_t

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

is_triggered

If the order has been triggered.

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

price

The order price (LIMIT).

Returns

Price

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

trigger_price

The order trigger price (STOP).

Returns

Price

trigger_type

The trigger type for the order.

Returns

TriggerType

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

ts_triggered

The UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Market-To-Limit

class MarketToLimitOrder ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , OrderSide order_side , Quantity quantity , UUID4 init_id , uint64_t ts_init , TimeInForce time_in_force=TimeInForce.GTC , uint64_t expire_time_ns=0 , bool reduce_only=False , Quantity display_qty=None , OrderListId order_list_id=None , ContingencyType contingency_type=ContingencyType.NONE , list linked_order_ids=None , ClientOrderId parent_order_id=None , unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Market-To-Limit order.

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

  • expire_time_ns ( uint64_t , default 0 ( no expiry ) ) – The UNIX timestamp (nanoseconds) when the order will expire.

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

  • display_qty ( Quantity , optional ) – The quantity of the limit order to display on the public book (iceberg).

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE .

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

display_qty

The quantity of the limit order to display on the public book (iceberg).

Returns

Quantity or None

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

expire_time

Return the expire time for the order (UTC).

Returns

datetime or None

expire_time_ns

The order expiration (UNIX epoch nanoseconds), zero for no expiration.

Returns

uint64_t

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

price

The order price (LIMIT).

Returns

Price or None

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Market-If-Touched

class MarketIfTouchedOrder ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , OrderSide order_side , Quantity quantity , Price trigger_price , TriggerType trigger_type , UUID4 init_id , uint64_t ts_init , TimeInForce time_in_force=TimeInForce.GTC , uint64_t expire_time_ns=0 , bool reduce_only=False , OrderListId order_list_id=None , ContingencyType contingency_type=ContingencyType.NONE , list linked_order_ids=None , ClientOrderId parent_order_id=None , unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Market-If-Touched (MIT) conditional order.

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • trigger_price ( Price ) – The order trigger price (STOP).

  • trigger_type ( TriggerType ) – The order trigger type.

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

  • expire_time_ns ( uint64_t , default 0 ( no expiry ) ) – The UNIX timestamp (nanoseconds) when the order will expire.

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

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If trigger_type is NONE .

  • ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE .

  • ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

expire_time

Return the expire time for the order (UTC).

Returns

datetime or None

expire_time_ns

The order expiration (UNIX epoch nanoseconds), zero for no expiration.

Returns

uint64_t

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

trigger_price

The order trigger price (STOP).

Returns

Price

trigger_type

The trigger type for the order.

Returns

TriggerType

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Limit-If-Touched

class LimitIfTouchedOrder ( TraderId trader_id , StrategyId strategy_id , InstrumentId instrument_id , ClientOrderId client_order_id , OrderSide order_side , Quantity quantity , Price price , Price trigger_price , TriggerType trigger_type , UUID4 init_id , uint64_t ts_init , TimeInForce time_in_force=TimeInForce.GTC , uint64_t expire_time_ns=0 , bool post_only=False , bool reduce_only=False , Quantity display_qty=None , OrderListId order_list_id=None , ContingencyType contingency_type=ContingencyType.NONE , list linked_order_ids=None , ClientOrderId parent_order_id=None , unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Limit-If-Touched (LIT) conditional order.

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • price ( Price ) – The order price (LIMIT).

  • trigger_price ( Price ) – The order trigger price (STOP).

  • trigger_type ( TriggerType ) – The order trigger type.

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

  • expire_time_ns ( uint64_t , default 0 ( no expiry ) ) – The UNIX timestamp (nanoseconds) when the order will expire.

  • post_only ( bool , default False ) – If the LIMIT order will only provide liquidity (once triggered).

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

  • display_qty ( Quantity , optional ) – The quantity of the LIMIT order to display on the public book (iceberg).

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If trigger_type is NONE .

  • ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE .

  • ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.

  • ValueError – If display_qty is negative (< 0) or greater than quantity .

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

display_qty

The quantity of the LIMIT order to display on the public book (iceberg).

Returns

Quantity or None

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

expire_time

Return the expire time for the order (UTC).

Returns

datetime or None

expire_time_ns

The order expiration (UNIX epoch nanoseconds), zero for no expiration.

Returns

uint64_t

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

is_triggered

If the order has been triggered.

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

price

The order price (LIMIT).

Returns

Price

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

trigger_price

The order trigger price (STOP).

Returns

Price

trigger_type

The trigger type for the order.

Returns

TriggerType

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

ts_triggered

The UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Trailing Stop-Market

class TrailingStopMarketOrder ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price trigger_price: Optional[Price], TriggerType trigger_type, trailing_offset: Decimal, TrailingOffsetType trailing_offset_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool reduce_only=False, OrderListId order_list_id=None, ContingencyType contingency_type=ContingencyType.NONE, list linked_order_ids=None, ClientOrderId parent_order_id=None, unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Trailing-Stop-Market conditional order.

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • trigger_price (Price, optional with no default so None must be passed explicitly) – The order trigger price (STOP). If None then will typically default to the delta of market price and trailing_offset .

  • trigger_type ( TriggerType ) – The order trigger type.

  • trailing_offset ( Decimal ) – The trailing offset for the trigger price (STOP).

  • trailing_offset_type ( TrailingOffsetType ) – The order trailing offset type.

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

  • expire_time_ns ( uint64_t , default 0 ( no expiry ) ) – The UNIX timestamp (nanoseconds) when the order will expire.

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

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If trigger_type is NONE .

  • ValueError – If trailing_offset_type is NONE .

  • ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE .

  • ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

expire_time

Return the expire time for the order (UTC).

Returns

datetime or None

expire_time_ns

The order expiration (UNIX epoch nanoseconds), zero for no expiration.

Returns

uint64_t

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

trailing_offset

The trailing offset for the orders trigger price (STOP).

Returns

Decimal

trailing_offset_type

The trailing offset type.

Returns

TrailingOffsetType

trigger_price

The order trigger price (STOP).

Returns

Price or None

trigger_type

The trigger type for the order.

Returns

TriggerType

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Trailing Stop-Limit

class TrailingStopLimitOrder ( TraderId trader_id, StrategyId strategy_id, InstrumentId instrument_id, ClientOrderId client_order_id, OrderSide order_side, Quantity quantity, Price price: Optional[Price], Price trigger_price: Optional[Price], TriggerType trigger_type, limit_offset: Decimal, trailing_offset: Decimal, TrailingOffsetType trailing_offset_type, UUID4 init_id, uint64_t ts_init, TimeInForce time_in_force=TimeInForce.GTC, uint64_t expire_time_ns=0, bool post_only=False, bool reduce_only=False, Quantity display_qty=None, OrderListId order_list_id=None, ContingencyType contingency_type=ContingencyType.NONE, list linked_order_ids=None, ClientOrderId parent_order_id=None, unicode tags=None )

Bases: nautilus_trader.model.orders.base.Order

Represents a Trailing-Stop-Limit conditional order.

Parameters
  • trader_id ( TraderId ) – The trader ID associated with the order.

  • strategy_id ( StrategyId ) – The strategy ID associated with the order.

  • instrument_id ( InstrumentId ) – The order instrument ID.

  • client_order_id ( ClientOrderId ) – The client order ID.

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

  • quantity ( Quantity ) – The order quantity (> 0).

  • price (Price, optional with no default so None must be passed explicitly) – The order price (LIMIT). If None then will typically default to the delta of market price and limit_offset .

  • trigger_price (Price, optional with no default so None must be passed explicitly) – The order trigger price (STOP). If None then will typically default to the delta of market price and trailing_offset .

  • trigger_type ( TriggerType ) – The order trigger type.

  • limit_offset ( Decimal ) – The trailing offset for the order price (LIMIT).

  • trailing_offset ( Decimal ) – The trailing offset for the order trigger price (STOP).

  • trailing_offset_type ( TrailingOffsetType ) – The order trailing offset type.

  • init_id ( UUID4 ) – The order initialization event ID.

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

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

  • expire_time_ns ( uint64_t , default 0 ( no expiry ) ) – The UNIX timestamp (nanoseconds) when the order will expire.

  • post_only ( bool , default False ) – If the LIMIT order will only provide liquidity (once triggered).

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

  • display_qty ( Quantity , optional ) – The quantity of the LIMIT order to display on the public book (iceberg).

  • order_list_id ( OrderListId , optional ) – The order list ID associated with the order.

  • contingency_type (ContingencyType, default NONE ) – The order contingency type.

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

  • parent_order_id ( ClientOrderId , optional ) – The order parent client order ID.

  • tags ( str , optional ) – The custom user tags for the order. These are optional and can contain any arbitrary delimiter if required.

Raises
  • ValueError – If order_side is NONE .

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

  • ValueError – If trigger_type is NONE .

  • ValueError – If trailing_offset_type is NONE .

  • ValueError – If time_in_force is AT_THE_OPEN or AT_THE_CLOSE .

  • ValueError – If time_in_force is GTD and expire_time_ns <= UNIX epoch.

  • ValueError – If display_qty is negative (< 0) or greater than quantity .

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

display_qty

The quantity of the LIMIT order to display on the public book (iceberg).

Returns

Quantity or None

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

expire_time

Return the expire time for the order (UTC).

Returns

datetime or None

expire_time_ns

The order expiration (UNIX epoch nanoseconds), zero for no expiration.

Returns

uint64_t

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

is_triggered

If the order has been triggered.

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

limit_offset

The trailing offset for the orders limit price.

Returns

Decimal

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

price

The order price (LIMIT).

Returns

Price or None

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

trailing_offset

The trailing offset for the orders trigger price (STOP).

Returns

Decimal

trailing_offset_type

The trailing offset type.

Returns

TrailingOffsetType

trigger_price

The order trigger price (STOP).

Returns

Price or None

trigger_type

The trigger type for the order.

Returns

TriggerType

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

ts_triggered

The UNIX timestamp (nanoseconds) when the order was triggered (0 if not triggered).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]

Order List

class OrderList ( OrderListId list_id , list orders )

Bases: object

Represents a list of bulk or related parent-child contingent orders.

Parameters
  • list_id ( OrderListId ) – The order list ID.

  • orders ( list [ Order ] ) – The order bulk for the list.

Raises
  • ValueError – If orders is empty.

  • ValueError – If orders contains a type other than Order .

first

The first order in the list (typically the parent).

Returns

list[Order]

id

The order list ID.

Returns

OrderListId

instrument_id

The instrument ID associated with the list.

Returns

InstrumentId

orders

The orders contained in the list.

Returns

list[Order]

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

Base

class Order ( OrderInitialized init )

Bases: object

The abstract base class for all orders.

Parameters

init ( OrderInitialized ) – The order initialized event.

Warning

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

account_id

The account ID associated with the order.

Returns

AccountId or None

apply ( self , OrderEvent event ) void

Apply the given order event to the order.

Parameters

event ( OrderEvent ) – The order event to apply.

Raises
  • ValueError – If self.client_order_id is not equal to event.client_order_id .

  • ValueError – If self.venue_order_id and event.venue_order_id are both not None , and are not equal.

  • InvalidStateTrigger – If event is not a valid trigger from the current order.status .

  • KeyError – If event is OrderFilled and event.trade_id already applied to the order.

avg_px

The order average fill price.

Returns

double

client_order_id

The client order ID.

Returns

ClientOrderId

static closing_side ( PositionSide side ) OrderSide

Return the order side needed to close a position with the given side.

Parameters

side (PositionSide { LONG , SHORT }) – The side of the position to close.

Returns

OrderSide

Raises

ValueError – If side is FLAT or invalid.

contingency_type

The orders contingency type.

Returns

ContingencyType

event_count

Return the count of events applied to the order.

Returns

int

events

Return the order events.

Returns

list[OrderEvent]

filled_qty

The order total filled quantity.

Returns

Quantity

has_price

Return whether the order has a price property.

Returns

bool

has_trigger_price

Return whether the order has a trigger_price property.

Returns

bool

info ( self ) unicode

Return a summary description of the order.

Returns

str

init_event

Return the initialization event for the order.

Returns

OrderInitialized

init_id

The event ID of the OrderInitialized event.

Returns

UUID4

instrument_id

The order instrument ID.

Returns

InstrumentId

is_aggressive

Return whether the order is aggressive ( order_type is MARKET ).

Returns

bool

is_buy

Return whether the order side is BUY .

Returns

bool

is_canceled

Return whether current status is CANCELED .

Returns

bool

is_child_order

Return whether the order has a parent order.

Returns

bool

is_closed

Return whether the order is closed.

An order is considered closed when its status can no longer change. The possible statuses of closed orders include;

  • DENIED

  • REJECTED

  • CANCELED

  • EXPIRED

  • FILLED

Returns

bool

is_contingency

Return whether the order has a contingency ( contingency_type is not NONE ).

Returns

bool

is_inflight

Return whether the order is in-flight (order request sent to the trading venue).

An order is considered in-flight when its status is any of;

  • SUBMITTED

  • PENDING_CANCEL

  • PENDING_UPDATE

Returns

bool

is_open

Return whether the order is open at the trading venue.

An order is considered open when its status is any of;

  • ACCEPTED

  • TRIGGERED

  • PENDING_CANCEL

  • PENDING_UPDATE

  • PARTIALLY_FILLED

Returns

bool

is_parent_order

Return whether the order has at least one child order.

Returns

bool

is_passive

Return whether the order is passive ( order_type not MARKET ).

Returns

bool

is_pending_cancel

Return whether the current status is PENDING_CANCEL .

Returns

bool

is_pending_update

Return whether the current status is PENDING_UPDATE .

Returns

bool

is_post_only

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

Returns

bool

is_reduce_only

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

Returns

bool

is_sell

Return whether the order side is SELL .

Returns

bool

last_event

Return the last event applied to the order.

Returns

OrderEvent

last_trade_id

The orders last trade match ID.

Returns

TradeId or None

leaves_qty

The order total leaves quantity.

Returns

Quantity

linked_order_ids

The orders linked client order ID(s).

Returns

list[ClientOrderId] or None

liquidity_side

The order liquidity side.

Returns

LiquiditySide

static opposite_side ( OrderSide side ) OrderSide

Return the opposite order side from the given side.

Parameters

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

Returns

OrderSide

Raises

ValueError – If side is invalid.

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 parent client order ID.

Returns

ClientOrderId or None

position_id

The position ID associated with the order.

Returns

PositionId

quantity

The order quantity.

Returns

Quantity

side

The order side.

Returns

OrderSide

side_string

Return the orders side as a string.

Returns

str

slippage

The order total price slippage.

Returns

double

status

Return the orders current status.

Returns

OrderStatus

strategy_id

The strategy ID associated with the order.

Returns

StrategyId

symbol

Return the orders ticker symbol.

Returns

Symbol

tags

The order custom user tags.

Returns

str or None

time_in_force

The order time in force.

Returns

TimeInForce

to_dict ( self ) dict

Return a dictionary representation of this object.

Returns

dict[str, object]

trade_ids

Return the trade match IDs.

Returns

list[TradeId]

trader_id

The trader ID associated with the position.

Returns

TraderId

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns

uint64_t

ts_last

The UNIX timestamp (nanoseconds) when the last fill occurred (0 for no fill).

Returns

uint64_t

venue

Return the orders trading venue.

Returns

Venue

venue_order_id

The venue assigned order ID.

Returns

VenueOrderId

venue_order_ids

Return the venue order IDs.

Returns

list[VenueOrderId]