Skip to content

OrderEvent

QuantConnect.Orders.OrderEvent

OrderEvent(
    order_id: int,
    symbol: Union[Symbol, str, BaseContract, Security],
    utc_time: Union[datetime, date],
    status: OrderStatus,
    direction: OrderDirection,
    fill_price: float,
    fill_quantity: float,
    order_fee: OrderFee,
    message: str = ...,
)
OrderEvent()
OrderEvent(
    order: Order,
    utc_time: Union[datetime, date],
    order_fee: OrderFee,
    message: str = ...,
)

Bases: Object

Order Event - Messaging class signifying a change in an order state and record the change in the user's algorithm portfolio

Signature descriptions:

  • Order Event Constructor.

  • Order Event empty constructor required for json converter

  • Helper Constructor using Order to Initialize.

Parameters:

Name Type Description Default
order_id Optional[int]

Id of the parent order

None
symbol Optional[Union[Symbol, str, BaseContract, Security]]

Asset Symbol

None
utc_time Optional[Union[datetime, date]]

Date/time of this event

None
status Optional[OrderStatus]

Status of the order

None
direction Optional[OrderDirection]

The direction of the order this event belongs to

None
fill_price Optional[float]

Fill price information if applicable.

None
fill_quantity Optional[float]

Fill quantity

None
order_fee Optional[OrderFee]

The order fee

None
message Optional[str]

Message from the exchange

...
order Optional[Order]

Order for this order status

None

order_id

order_id: int

Id of the order this event comes from.

id

id: int

The unique order event id for each order

symbol

symbol: Symbol

Easy access to the order symbol associated with this event.

utc_time

utc_time: datetime

The date and time of this event (UTC).

time

time: datetime

The date and time of this event (UTC). Synonym of utc_time

status

status: OrderStatus

Status message of the order.

order_fee

order_fee: OrderFee

The fee associated with the order

fill_price

fill_price: float

Fill price information about the order

fill_price_currency

fill_price_currency: str

Currency for the fill price

fill_quantity

fill_quantity: float

Number of shares of the order that was filled in this event.

absolute_fill_quantity

absolute_fill_quantity: float

Public Property Absolute Getter of Quantity -Filled

direction

direction: OrderDirection

Order direction.

order_type

order_type: Optional[OrderType]

The type of the order this event comes from. Null for events built from the order id alone until the transaction handler stamps it, and for payloads that predate this property

group_id

group_id: Optional[int]

The id of the group of orders the order belongs to if it is a combo order leg, null otherwise

message

message: str

Any message from the exchange.

tag

tag: str

The tag of the order this event comes from. Null for events built from the order id alone until the transaction handler stamps it, and for deserialized events

is_assignment

is_assignment: bool

True if the order event is an assignment

stop_price

stop_price: Optional[float]

The current stop price

trigger_price

trigger_price: Optional[float]

The current trigger price

limit_price

limit_price: Optional[float]

The current limit price

quantity

quantity: float

The current order quantity

is_in_the_money

is_in_the_money: bool

True if the order event's option is In-The-Money (ITM)

trailing_amount

trailing_amount: Optional[float]

The trailing stop amount

trailing_as_percentage

trailing_as_percentage: Optional[bool]

Whether the trailing_amount is a percentage or an absolute currency value

ticket

ticket: OrderTicket

The order ticket associated to the order

clone

clone() -> OrderEvent

Returns a clone of the current object.

Returns:

Type Description
OrderEvent

The new clone object.

from_serialized

from_serialized(
    serialized_order_event: SerializedOrderEvent,
) -> OrderEvent

Creates a new instance based on the provided serialized order event

is_win

is_win(security: Security, profit_loss: float) -> bool

Checks whether the fill event for closing a trade is a winning trade

Parameters:

Name Type Description Default
security Security

The security being traded

required
profit_loss float

The profit-loss for the closed trade

required

Returns:

Type Description
bool

Whether the trade is a win. For options assignments this depends on whether the option is ITM or OTM and the position side. See Trade.IsWin for more information.

short_to_string

short_to_string() -> str

Returns a short string that represents the current object.

to_string

to_string() -> str

Returns a string that represents the current object.

Returns:

Type Description
str

A string that represents the current object.