IOrder
Previous Topic  Next Topic 

Definition
Represents a read only interface that exposes information regarding an order.


Methods and Properties

Action

Possible values are:


Action.Buy

Action.BuyToCover

Action.Sell

Action.SellShort

AvgFillPrice

A double value representing the average fill price of an order

Filled

An int value representing the filled amount of an order

FromEntrySignal

A string representing the user defined fromEntrySignal parameter on an order

Instrument

An Instrument value representing the instrument of an order

LimitPrice

A double value representing the limit price of an order

LiveUntilCancelled

*A bool value representing if the order is live until cancelled by the user

Name

A string representing the name of an order which can be provided by the entry or exit signal name

Oco

A string representing the OCO (one cancels other) id of an order

OrderId

A string representing the broker issued order id value (this value can change)

OrderState

See table below

OrderType

Possible values are:


OrderType.Limit

OrderType.Market

OrderType.Stop

OrderType.StopLimit

Quantity

An int value representing the quantity of an order

StopPrice

A double value representing the stop price of an order

Time

A DateTime structure representing the last time the order changed state

TimeInForce

Possible values are:


TimeInForce.Day

TimeInForce.Gtc

Token

A string representing the unique id of an order

ToString()

A string representation of an order


OrderState Values

OrderState.Accepted

Order has been acknowledged by the broker

OrderState.Cancelled

Order has been cancelled

OrderState.Filled

Order has been filled

OrderState.PartFilled

Order has been part filled

OrderState.PendingCancel

An order cancellation request has been submitted

OrderState.PendingChange

An order change request has been submitted

OrderState.PendingSubmit

An order has been submitted

OrderState.Rejected

An order has been rejected

OrderState.Working

An order is working at the exchange

OrderState.Unknown

An unknown order state

* In a historical backtest, orders will always reach a "Working" state.
** In real-time, some stop orders may only reach "Accepted" state if they are simulated/held on a brokers server


Examples

private IOrder entryOrder = null;

protected override void OnBarUpdate()
{
    if (entryOrder == null && Close[0] > Open[0])
        entryOrder = EnterLong();
}

protected override void OnOrderUpdate(IOrder order)
{
    if (entryOrder != null && entryOrder.Token == order.Token)
    {
        Print(order.ToString());
        if (order.OrderState == OrderState.Filled)
            entryOrder = null;
     }
}


Tips
1. Not all connectivity providers support all MarketDataTypes.