Skip to content

OrderTicket

QuantConnect.Orders.OrderTicket

OrderTicket(
    transaction_manager: SecurityTransactionManager,
    submit_request: SubmitOrderRequest,
)

Bases: Object

Provides a single reference to an order for the algorithm to maintain. As the order gets updated this ticket will also get updated

Initializes a new instance of the OrderTicket class

Parameters:

Name Type Description Default
transaction_manager SecurityTransactionManager

The transaction manager used for submitting updates and cancels for this ticket

required
submit_request SubmitOrderRequest

The order request that initiated this order ticket

required

order_id

order_id: int

Gets the order id of this ticket

status

status: OrderStatus

Gets the current status of this order ticket

symbol

symbol: Symbol

Gets the symbol being ordered

security_type

security_type: SecurityType

Gets the symbol's security_type

quantity

quantity: float

Gets the number of units ordered

average_fill_price

average_fill_price: float

Gets the average fill price for this ticket. If no fills have been processed then this will return a value of zero.

quantity_filled

quantity_filled: float

Gets the total qantity filled for this ticket. If no fills have been processed then this will return a value of zero.

quantity_remaining

quantity_remaining: float

Gets the remaining quantity for this order ticket. This is the difference between the total quantity ordered and the total quantity filled.

time

time: datetime

Gets the time this order was last updated

order_type

order_type: OrderType

Gets the type of order

tag

tag: str

Gets the order's current tag

submit_request

submit_request: SubmitOrderRequest

Gets the SubmitOrderRequest that initiated this order

update_requests

update_requests: Sequence[UpdateOrderRequest]

Gets a list of UpdateOrderRequest containing an item for each UpdateOrderRequest that was sent for this order id

cancel_request

cancel_request: CancelOrderRequest

Gets the CancelOrderRequest if this order was canceled. If this order was not canceled, this will return null

order_events

order_events: Sequence[OrderEvent]

Gets a list of all order events for this ticket

order_closed

order_closed: WaitHandle

Gets a wait handle that can be used to wait until this order has filled

has_order

has_order: bool

Returns true if the order has been set for this ticket

order_set

order_set: WaitHandle

Gets a wait handle that can be used to wait until the order has been set

cancel

cancel(tag: str = None) -> OrderResponse

Submits a new request to cancel this order

get

get(field: OrderField) -> float

Gets the specified field from the ticket

Parameters:

Name Type Description Default
field OrderField

The order field to get

required

Returns:

Type Description
float

The value of the field.

get_most_recent_order_request

get_most_recent_order_request() -> OrderRequest

Gets the most recent OrderRequest for this ticket

Returns:

Type Description
OrderRequest

The most recent OrderRequest for this ticket.

get_most_recent_order_response

get_most_recent_order_response() -> OrderResponse

Gets the most recent OrderResponse for this ticket

Returns:

Type Description
OrderResponse

The most recent OrderResponse for this ticket.

invalid_cancel_order_id

invalid_cancel_order_id(
    transaction_manager: SecurityTransactionManager,
    request: CancelOrderRequest,
) -> OrderTicket

Creates a new OrderTicket that represents trying to cancel an order for which no ticket exists

invalid_submit_request

invalid_submit_request(
    transaction_manager: SecurityTransactionManager,
    request: SubmitOrderRequest,
    response: OrderResponse,
) -> OrderTicket

Creates a new OrderTicket that represents trying to submit a new order that had errors embodied in the response

invalid_update_order_id

invalid_update_order_id(
    transaction_manager: SecurityTransactionManager,
    request: UpdateOrderRequest,
) -> OrderTicket

Creates a new OrderTicket that represents trying to update an order for which no ticket exists

to_string

to_string() -> str

Returns a string that represents the current object.

Returns:

Type Description
str

A string that represents the current object.

update

update(fields: UpdateOrderFields) -> OrderResponse

Submits an UpdateOrderRequest with the SecurityTransactionManager to update the ticket with data specified in fields

Parameters:

Name Type Description Default
fields UpdateOrderFields

Defines what properties of the order should be updated

required

Returns:

Type Description
OrderResponse

The OrderResponse from updating the order.

update_limit_price

update_limit_price(
    limit_price: float, tag: str = None
) -> OrderResponse

Submits an UpdateOrderRequest with the SecurityTransactionManager to update the ticker with limit price specified in limit_price and with tag specified in tag

Parameters:

Name Type Description Default
limit_price float

The new limit price for this order ticket

required
tag str

The new tag for this order ticket

None

Returns:

Type Description
OrderResponse

OrderResponse from updating the order.

update_quantity

update_quantity(
    quantity: float, tag: str = None
) -> OrderResponse

Submits an UpdateOrderRequest with the SecurityTransactionManager to update the ticket with quantity specified in quantity and with tag specified in quantity

Parameters:

Name Type Description Default
quantity float

The new quantity for this order ticket

required
tag str

The new tag for this order ticket

None

Returns:

Type Description
OrderResponse

OrderResponse from updating the order.

update_stop_price

update_stop_price(
    stop_price: float, tag: str = None
) -> OrderResponse

Submits an UpdateOrderRequest with the SecurityTransactionManager to update the ticker with stop price specified in stop_price and with tag specified in tag

Parameters:

Name Type Description Default
stop_price float

The new stop price for this order ticket

required
tag str

The new tag for this order ticket

None

Returns:

Type Description
OrderResponse

OrderResponse from updating the order.

update_stop_trailing_amount

update_stop_trailing_amount(
    trailing_amount: float, tag: str = None
) -> OrderResponse

Submits an UpdateOrderRequest with the SecurityTransactionManager to update the ticker with stop trailing amount specified in trailing_amount and with tag specified in tag

Parameters:

Name Type Description Default
trailing_amount float

The new trailing amount for this order ticket

required
tag str

The new tag for this order ticket

None

Returns:

Type Description
OrderResponse

OrderResponse from updating the order.

update_tag

update_tag(tag: str) -> OrderResponse

Submits an UpdateOrderRequest with the SecurityTransactionManager to update the ticket with tag specified in tag

Parameters:

Name Type Description Default
tag str

The new tag for this order ticket

required

Returns:

Type Description
OrderResponse

OrderResponse from updating the order.

update_trigger_price

update_trigger_price(
    trigger_price: float, tag: str = None
) -> OrderResponse

Submits an UpdateOrderRequest with the SecurityTransactionManager to update the ticker with trigger price specified in trigger_price and with tag specified in tag

Parameters:

Name Type Description Default
trigger_price float

The new price which, when touched, will trigger the setting of a limit order.

required
tag str

The new tag for this order ticket

None

Returns:

Type Description
OrderResponse

OrderResponse from updating the order.