Which API should I use?

  • Use v20 REST API only if you have a v20 account
  • Use v1 REST API if your account id contains only digits (ie. 2534253) as it is a legacy account

Order Definitions


Orders

The specification of all Orders supported by the platform.

Implemented by: MarketOrder, LimitOrder, StopOrder, MarketIfTouchedOrder, TakeProfitOrder, StopLossOrder, TrailingStopLossOrder

Order is an application/json object with the following Schema:

{
    # 
    # The Order’s identifier, unique within the Order’s Account.
    # 
    id : (OrderID),

    # 
    # The time when the Order was created.
    # 
    createTime : (DateTime),

    # 
    # The current state of the Order.
    # 
    state : (OrderState),

    # 
    # The client extensions of the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions)
}

MarketOrder is an application/json object with the following Schema:

{
    # 
    # The Order’s identifier, unique within the Order’s Account.
    # 
    id : (OrderID),

    # 
    # The time when the Order was created.
    # 
    createTime : (DateTime),

    # 
    # The current state of the Order.
    # 
    state : (OrderState),

    # 
    # The client extensions of the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # The type of the Order. Always set to “MARKET” for Market Orders.
    # 
    type : (OrderType, default=MARKET),

    # 
    # The Market Order’s Instrument.
    # 
    instrument : (InstrumentName, required),

    # 
    # The quantity requested to be filled by the Market Order. A posititive
    # number of units results in a long Order, and a negative number of units
    # results in a short Order.
    # 
    units : (DecimalNumber, required),

    # 
    # The time-in-force requested for the Market Order. Restricted to FOK or
    # IOC for a MarketOrder.
    # 
    timeInForce : (TimeInForce, required, default=FOK),

    # 
    # The worst price that the client is willing to have the Market Order
    # filled at.
    # 
    priceBound : (PriceValue),

    # 
    # Specification of how Positions in the Account are modified when the Order
    # is filled.
    # 
    positionFill : (OrderPositionFill, required, default=DEFAULT),

    # 
    # Details of the Trade requested to be closed, only provided when the
    # Market Order is being used to explicitly close a Trade.
    # 
    tradeClose : (MarketOrderTradeClose),

    # 
    # Details of the long Position requested to be closed out, only provided
    # when a Market Order is being used to explicitly closeout a long Position.
    # 
    longPositionCloseout : (MarketOrderPositionCloseout),

    # 
    # Details of the short Position requested to be closed out, only provided
    # when a Market Order is being used to explicitly closeout a short
    # Position.
    # 
    shortPositionCloseout : (MarketOrderPositionCloseout),

    # 
    # Details of the Margin Closeout that this Market Order was created for
    # 
    marginCloseout : (MarketOrderMarginCloseout),

    # 
    # Details of the delayed Trade close that this Market Order was created for
    # 
    delayedTradeClose : (MarketOrderDelayedTradeClose),

    # 
    # TakeProfitDetails specifies the details of a Take Profit Order to be
    # created on behalf of a client. This may happen when an Order is filled
    # that opens a Trade requiring a Take Profit, or when a Trade’s dependent
    # Take Profit Order is modified directly through the Trade.
    # 
    takeProfitOnFill : (TakeProfitDetails),

    # 
    # StopLossDetails specifies the details of a Stop Loss Order to be created
    # on behalf of a client. This may happen when an Order is filled that opens
    # a Trade requiring a Stop Loss, or when a Trade’s dependent Stop Loss
    # Order is modified directly through the Trade.
    # 
    stopLossOnFill : (StopLossDetails),

    # 
    # TrailingStopLossDetails specifies the details of a Trailing Stop Loss
    # Order to be created on behalf of a client. This may happen when an Order
    # is filled that opens a Trade requiring a Trailing Stop Loss, or when a
    # Trade’s dependent Trailing Stop Loss Order is modified directly through
    # the Trade.
    # 
    trailingStopLossOnFill : (TrailingStopLossDetails),

    # 
    # Client Extensions to add to the Trade created when the Order is filled
    # (if such a Trade is created). Do not set, modify, or delete
    # tradeClientExtensions if your account is associated with MT4.
    # 
    tradeClientExtensions : (ClientExtensions),

    # 
    # ID of the Transaction that filled this Order (only provided when the
    # Order’s state is FILLED)
    # 
    fillingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was filled (only provided when the Order’s state
    # is FILLED)
    # 
    filledTime : (DateTime),

    # 
    # Trade ID of Trade opened when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was opened as a result of the
    # fill)
    # 
    tradeOpenedID : (TradeID),

    # 
    # Trade ID of Trade reduced when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was reduced as a result of the
    # fill)
    # 
    tradeReducedID : (TradeID),

    # 
    # Trade IDs of Trades closed when the Order was filled (only provided when
    # the Order’s state is FILLED and one or more Trades were closed as a
    # result of the fill)
    # 
    tradeClosedIDs : (Array[TradeID]),

    # 
    # ID of the Transaction that cancelled the Order (only provided when the
    # Order’s state is CANCELLED)
    # 
    cancellingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was cancelled (only provided when the state of
    # the Order is CANCELLED)
    # 
    cancelledTime : (DateTime)
}

LimitOrder is an application/json object with the following Schema:

{
    # 
    # The Order’s identifier, unique within the Order’s Account.
    # 
    id : (OrderID),

    # 
    # The time when the Order was created.
    # 
    createTime : (DateTime),

    # 
    # The current state of the Order.
    # 
    state : (OrderState),

    # 
    # The client extensions of the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # The type of the Order. Always set to “LIMIT” for Limit Orders.
    # 
    type : (OrderType, default=LIMIT),

    # 
    # The Limit Order’s Instrument.
    # 
    instrument : (InstrumentName, required),

    # 
    # The quantity requested to be filled by the Limit Order. A posititive
    # number of units results in a long Order, and a negative number of units
    # results in a short Order.
    # 
    units : (DecimalNumber, required),

    # 
    # The price threshold specified for the Limit Order. The Limit Order will
    # only be filled by a market price that is equal to or better than this
    # price.
    # 
    price : (PriceValue, required),

    # 
    # The time-in-force requested for the Limit Order.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the Limit Order will be cancelled if its timeInForce
    # is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of how Positions in the Account are modified when the Order
    # is filled.
    # 
    positionFill : (OrderPositionFill, required, default=DEFAULT),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # TakeProfitDetails specifies the details of a Take Profit Order to be
    # created on behalf of a client. This may happen when an Order is filled
    # that opens a Trade requiring a Take Profit, or when a Trade’s dependent
    # Take Profit Order is modified directly through the Trade.
    # 
    takeProfitOnFill : (TakeProfitDetails),

    # 
    # StopLossDetails specifies the details of a Stop Loss Order to be created
    # on behalf of a client. This may happen when an Order is filled that opens
    # a Trade requiring a Stop Loss, or when a Trade’s dependent Stop Loss
    # Order is modified directly through the Trade.
    # 
    stopLossOnFill : (StopLossDetails),

    # 
    # TrailingStopLossDetails specifies the details of a Trailing Stop Loss
    # Order to be created on behalf of a client. This may happen when an Order
    # is filled that opens a Trade requiring a Trailing Stop Loss, or when a
    # Trade’s dependent Trailing Stop Loss Order is modified directly through
    # the Trade.
    # 
    trailingStopLossOnFill : (TrailingStopLossDetails),

    # 
    # Client Extensions to add to the Trade created when the Order is filled
    # (if such a Trade is created). Do not set, modify, or delete
    # tradeClientExtensions if your account is associated with MT4.
    # 
    tradeClientExtensions : (ClientExtensions),

    # 
    # ID of the Transaction that filled this Order (only provided when the
    # Order’s state is FILLED)
    # 
    fillingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was filled (only provided when the Order’s state
    # is FILLED)
    # 
    filledTime : (DateTime),

    # 
    # Trade ID of Trade opened when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was opened as a result of the
    # fill)
    # 
    tradeOpenedID : (TradeID),

    # 
    # Trade ID of Trade reduced when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was reduced as a result of the
    # fill)
    # 
    tradeReducedID : (TradeID),

    # 
    # Trade IDs of Trades closed when the Order was filled (only provided when
    # the Order’s state is FILLED and one or more Trades were closed as a
    # result of the fill)
    # 
    tradeClosedIDs : (Array[TradeID]),

    # 
    # ID of the Transaction that cancelled the Order (only provided when the
    # Order’s state is CANCELLED)
    # 
    cancellingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was cancelled (only provided when the state of
    # the Order is CANCELLED)
    # 
    cancelledTime : (DateTime),

    # 
    # The ID of the Order that was replaced by this Order (only provided if
    # this Order was created as part of a cancel/replace).
    # 
    replacesOrderID : (OrderID),

    # 
    # The ID of the Order that replaced this Order (only provided if this Order
    # was cancelled as part of a cancel/replace).
    # 
    replacedByOrderID : (OrderID)
}

StopOrder is an application/json object with the following Schema:

{
    # 
    # The Order’s identifier, unique within the Order’s Account.
    # 
    id : (OrderID),

    # 
    # The time when the Order was created.
    # 
    createTime : (DateTime),

    # 
    # The current state of the Order.
    # 
    state : (OrderState),

    # 
    # The client extensions of the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # The type of the Order. Always set to “STOP” for Stop Orders.
    # 
    type : (OrderType, default=STOP),

    # 
    # The Stop Order’s Instrument.
    # 
    instrument : (InstrumentName, required),

    # 
    # The quantity requested to be filled by the Stop Order. A posititive
    # number of units results in a long Order, and a negative number of units
    # results in a short Order.
    # 
    units : (DecimalNumber, required),

    # 
    # The price threshold specified for the Stop Order. The Stop Order will
    # only be filled by a market price that is equal to or worse than this
    # price.
    # 
    price : (PriceValue, required),

    # 
    # The worst market price that may be used to fill this Stop Order. If the
    # market gaps and crosses through both the price and the priceBound, the
    # Stop Order will be cancelled instead of being filled.
    # 
    priceBound : (PriceValue),

    # 
    # The time-in-force requested for the Stop Order.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the Stop Order will be cancelled if its timeInForce is
    # “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of how Positions in the Account are modified when the Order
    # is filled.
    # 
    positionFill : (OrderPositionFill, required, default=DEFAULT),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # TakeProfitDetails specifies the details of a Take Profit Order to be
    # created on behalf of a client. This may happen when an Order is filled
    # that opens a Trade requiring a Take Profit, or when a Trade’s dependent
    # Take Profit Order is modified directly through the Trade.
    # 
    takeProfitOnFill : (TakeProfitDetails),

    # 
    # StopLossDetails specifies the details of a Stop Loss Order to be created
    # on behalf of a client. This may happen when an Order is filled that opens
    # a Trade requiring a Stop Loss, or when a Trade’s dependent Stop Loss
    # Order is modified directly through the Trade.
    # 
    stopLossOnFill : (StopLossDetails),

    # 
    # TrailingStopLossDetails specifies the details of a Trailing Stop Loss
    # Order to be created on behalf of a client. This may happen when an Order
    # is filled that opens a Trade requiring a Trailing Stop Loss, or when a
    # Trade’s dependent Trailing Stop Loss Order is modified directly through
    # the Trade.
    # 
    trailingStopLossOnFill : (TrailingStopLossDetails),

    # 
    # Client Extensions to add to the Trade created when the Order is filled
    # (if such a Trade is created). Do not set, modify, or delete
    # tradeClientExtensions if your account is associated with MT4.
    # 
    tradeClientExtensions : (ClientExtensions),

    # 
    # ID of the Transaction that filled this Order (only provided when the
    # Order’s state is FILLED)
    # 
    fillingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was filled (only provided when the Order’s state
    # is FILLED)
    # 
    filledTime : (DateTime),

    # 
    # Trade ID of Trade opened when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was opened as a result of the
    # fill)
    # 
    tradeOpenedID : (TradeID),

    # 
    # Trade ID of Trade reduced when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was reduced as a result of the
    # fill)
    # 
    tradeReducedID : (TradeID),

    # 
    # Trade IDs of Trades closed when the Order was filled (only provided when
    # the Order’s state is FILLED and one or more Trades were closed as a
    # result of the fill)
    # 
    tradeClosedIDs : (Array[TradeID]),

    # 
    # ID of the Transaction that cancelled the Order (only provided when the
    # Order’s state is CANCELLED)
    # 
    cancellingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was cancelled (only provided when the state of
    # the Order is CANCELLED)
    # 
    cancelledTime : (DateTime),

    # 
    # The ID of the Order that was replaced by this Order (only provided if
    # this Order was created as part of a cancel/replace).
    # 
    replacesOrderID : (OrderID),

    # 
    # The ID of the Order that replaced this Order (only provided if this Order
    # was cancelled as part of a cancel/replace).
    # 
    replacedByOrderID : (OrderID)
}

MarketIfTouchedOrder is an application/json object with the following Schema:

{
    # 
    # The Order’s identifier, unique within the Order’s Account.
    # 
    id : (OrderID),

    # 
    # The time when the Order was created.
    # 
    createTime : (DateTime),

    # 
    # The current state of the Order.
    # 
    state : (OrderState),

    # 
    # The client extensions of the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # The type of the Order. Always set to “MARKET_IF_TOUCHED” for Market If
    # Touched Orders.
    # 
    type : (OrderType, default=MARKET_IF_TOUCHED),

    # 
    # The MarketIfTouched Order’s Instrument.
    # 
    instrument : (InstrumentName, required),

    # 
    # The quantity requested to be filled by the MarketIfTouched Order. A
    # posititive number of units results in a long Order, and a negative number
    # of units results in a short Order.
    # 
    units : (DecimalNumber, required),

    # 
    # The price threshold specified for the MarketIfTouched Order. The
    # MarketIfTouched Order will only be filled by a market price that crosses
    # this price from the direction of the market price at the time when the
    # Order was created (the initialMarketPrice). Depending on the value of the
    # Order’s price and initialMarketPrice, the MarketIfTouchedOrder will
    # behave like a Limit or a Stop Order.
    # 
    price : (PriceValue, required),

    # 
    # The worst market price that may be used to fill this MarketIfTouched
    # Order.
    # 
    priceBound : (PriceValue),

    # 
    # The time-in-force requested for the MarketIfTouched Order. Restricted to
    # “GTC”, “GFD” and “GTD” for MarketIfTouched Orders.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the MarketIfTouched Order will be cancelled if its
    # timeInForce is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of how Positions in the Account are modified when the Order
    # is filled.
    # 
    positionFill : (OrderPositionFill, required, default=DEFAULT),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # The Market price at the time when the MarketIfTouched Order was created.
    # 
    initialMarketPrice : (PriceValue),

    # 
    # TakeProfitDetails specifies the details of a Take Profit Order to be
    # created on behalf of a client. This may happen when an Order is filled
    # that opens a Trade requiring a Take Profit, or when a Trade’s dependent
    # Take Profit Order is modified directly through the Trade.
    # 
    takeProfitOnFill : (TakeProfitDetails),

    # 
    # StopLossDetails specifies the details of a Stop Loss Order to be created
    # on behalf of a client. This may happen when an Order is filled that opens
    # a Trade requiring a Stop Loss, or when a Trade’s dependent Stop Loss
    # Order is modified directly through the Trade.
    # 
    stopLossOnFill : (StopLossDetails),

    # 
    # TrailingStopLossDetails specifies the details of a Trailing Stop Loss
    # Order to be created on behalf of a client. This may happen when an Order
    # is filled that opens a Trade requiring a Trailing Stop Loss, or when a
    # Trade’s dependent Trailing Stop Loss Order is modified directly through
    # the Trade.
    # 
    trailingStopLossOnFill : (TrailingStopLossDetails),

    # 
    # Client Extensions to add to the Trade created when the Order is filled
    # (if such a Trade is created). Do not set, modify, or delete
    # tradeClientExtensions if your account is associated with MT4.
    # 
    tradeClientExtensions : (ClientExtensions),

    # 
    # ID of the Transaction that filled this Order (only provided when the
    # Order’s state is FILLED)
    # 
    fillingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was filled (only provided when the Order’s state
    # is FILLED)
    # 
    filledTime : (DateTime),

    # 
    # Trade ID of Trade opened when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was opened as a result of the
    # fill)
    # 
    tradeOpenedID : (TradeID),

    # 
    # Trade ID of Trade reduced when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was reduced as a result of the
    # fill)
    # 
    tradeReducedID : (TradeID),

    # 
    # Trade IDs of Trades closed when the Order was filled (only provided when
    # the Order’s state is FILLED and one or more Trades were closed as a
    # result of the fill)
    # 
    tradeClosedIDs : (Array[TradeID]),

    # 
    # ID of the Transaction that cancelled the Order (only provided when the
    # Order’s state is CANCELLED)
    # 
    cancellingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was cancelled (only provided when the state of
    # the Order is CANCELLED)
    # 
    cancelledTime : (DateTime),

    # 
    # The ID of the Order that was replaced by this Order (only provided if
    # this Order was created as part of a cancel/replace).
    # 
    replacesOrderID : (OrderID),

    # 
    # The ID of the Order that replaced this Order (only provided if this Order
    # was cancelled as part of a cancel/replace).
    # 
    replacedByOrderID : (OrderID)
}

TakeProfitOrder is an application/json object with the following Schema:

{
    # 
    # The Order’s identifier, unique within the Order’s Account.
    # 
    id : (OrderID),

    # 
    # The time when the Order was created.
    # 
    createTime : (DateTime),

    # 
    # The current state of the Order.
    # 
    state : (OrderState),

    # 
    # The client extensions of the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # The type of the Order. Always set to “TAKE_PROFIT” for Take Profit
    # Orders.
    # 
    type : (OrderType, default=TAKE_PROFIT),

    # 
    # The ID of the Trade to close when the price threshold is breached.
    # 
    tradeID : (TradeID, required),

    # 
    # The client ID of the Trade to be closed when the price threshold is
    # breached.
    # 
    clientTradeID : (ClientID),

    # 
    # The price threshold specified for the TakeProfit Order. The associated
    # Trade will be closed by a market price that is equal to or better than
    # this threshold.
    # 
    price : (PriceValue, required),

    # 
    # The time-in-force requested for the TakeProfit Order. Restricted to
    # “GTC”, “GFD” and “GTD” for TakeProfit Orders.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the TakeProfit Order will be cancelled if its
    # timeInForce is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # ID of the Transaction that filled this Order (only provided when the
    # Order’s state is FILLED)
    # 
    fillingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was filled (only provided when the Order’s state
    # is FILLED)
    # 
    filledTime : (DateTime),

    # 
    # Trade ID of Trade opened when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was opened as a result of the
    # fill)
    # 
    tradeOpenedID : (TradeID),

    # 
    # Trade ID of Trade reduced when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was reduced as a result of the
    # fill)
    # 
    tradeReducedID : (TradeID),

    # 
    # Trade IDs of Trades closed when the Order was filled (only provided when
    # the Order’s state is FILLED and one or more Trades were closed as a
    # result of the fill)
    # 
    tradeClosedIDs : (Array[TradeID]),

    # 
    # ID of the Transaction that cancelled the Order (only provided when the
    # Order’s state is CANCELLED)
    # 
    cancellingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was cancelled (only provided when the state of
    # the Order is CANCELLED)
    # 
    cancelledTime : (DateTime),

    # 
    # The ID of the Order that was replaced by this Order (only provided if
    # this Order was created as part of a cancel/replace).
    # 
    replacesOrderID : (OrderID),

    # 
    # The ID of the Order that replaced this Order (only provided if this Order
    # was cancelled as part of a cancel/replace).
    # 
    replacedByOrderID : (OrderID)
}

StopLossOrder is an application/json object with the following Schema:

{
    # 
    # The Order’s identifier, unique within the Order’s Account.
    # 
    id : (OrderID),

    # 
    # The time when the Order was created.
    # 
    createTime : (DateTime),

    # 
    # The current state of the Order.
    # 
    state : (OrderState),

    # 
    # The client extensions of the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # The type of the Order. Always set to “STOP_LOSS” for Stop Loss Orders.
    # 
    type : (OrderType, default=STOP_LOSS),

    # 
    # The ID of the Trade to close when the price threshold is breached.
    # 
    tradeID : (TradeID, required),

    # 
    # The client ID of the Trade to be closed when the price threshold is
    # breached.
    # 
    clientTradeID : (ClientID),

    # 
    # The price threshold specified for the StopLoss Order. The associated
    # Trade will be closed by a market price that is equal to or worse than
    # this threshold.
    # 
    price : (PriceValue, required),

    # 
    # The time-in-force requested for the StopLoss Order. Restricted to “GTC”,
    # “GFD” and “GTD” for StopLoss Orders.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the StopLoss Order will be cancelled if its
    # timeInForce is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # ID of the Transaction that filled this Order (only provided when the
    # Order’s state is FILLED)
    # 
    fillingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was filled (only provided when the Order’s state
    # is FILLED)
    # 
    filledTime : (DateTime),

    # 
    # Trade ID of Trade opened when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was opened as a result of the
    # fill)
    # 
    tradeOpenedID : (TradeID),

    # 
    # Trade ID of Trade reduced when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was reduced as a result of the
    # fill)
    # 
    tradeReducedID : (TradeID),

    # 
    # Trade IDs of Trades closed when the Order was filled (only provided when
    # the Order’s state is FILLED and one or more Trades were closed as a
    # result of the fill)
    # 
    tradeClosedIDs : (Array[TradeID]),

    # 
    # ID of the Transaction that cancelled the Order (only provided when the
    # Order’s state is CANCELLED)
    # 
    cancellingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was cancelled (only provided when the state of
    # the Order is CANCELLED)
    # 
    cancelledTime : (DateTime),

    # 
    # The ID of the Order that was replaced by this Order (only provided if
    # this Order was created as part of a cancel/replace).
    # 
    replacesOrderID : (OrderID),

    # 
    # The ID of the Order that replaced this Order (only provided if this Order
    # was cancelled as part of a cancel/replace).
    # 
    replacedByOrderID : (OrderID)
}

TrailingStopLossOrder is an application/json object with the following Schema:

{
    # 
    # The Order’s identifier, unique within the Order’s Account.
    # 
    id : (OrderID),

    # 
    # The time when the Order was created.
    # 
    createTime : (DateTime),

    # 
    # The current state of the Order.
    # 
    state : (OrderState),

    # 
    # The client extensions of the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # The type of the Order. Always set to “TRAILING_STOP_LOSS” for Trailing
    # Stop Loss Orders.
    # 
    type : (OrderType, default=TRAILING_STOP_LOSS),

    # 
    # The ID of the Trade to close when the price threshold is breached.
    # 
    tradeID : (TradeID, required),

    # 
    # The client ID of the Trade to be closed when the price threshold is
    # breached.
    # 
    clientTradeID : (ClientID),

    # 
    # The price distance specified for the TrailingStopLoss Order.
    # 
    distance : (PriceValue, required),

    # 
    # The time-in-force requested for the TrailingStopLoss Order. Restricted to
    # “GTC”, “GFD” and “GTD” for TrailingStopLoss Orders.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the StopLoss Order will be cancelled if its
    # timeInForce is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # The trigger price for the Trailing Stop Loss Order. The trailing stop
    # value will trail (follow) the market price by the TSL order’s configured
    # “distance” as the market price moves in the winning direction. If the
    # market price moves to a level that is equal to or worse than the trailing
    # stop value, the order will be filled and the Trade will be closed.
    # 
    trailingStopValue : (PriceValue),

    # 
    # ID of the Transaction that filled this Order (only provided when the
    # Order’s state is FILLED)
    # 
    fillingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was filled (only provided when the Order’s state
    # is FILLED)
    # 
    filledTime : (DateTime),

    # 
    # Trade ID of Trade opened when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was opened as a result of the
    # fill)
    # 
    tradeOpenedID : (TradeID),

    # 
    # Trade ID of Trade reduced when the Order was filled (only provided when
    # the Order’s state is FILLED and a Trade was reduced as a result of the
    # fill)
    # 
    tradeReducedID : (TradeID),

    # 
    # Trade IDs of Trades closed when the Order was filled (only provided when
    # the Order’s state is FILLED and one or more Trades were closed as a
    # result of the fill)
    # 
    tradeClosedIDs : (Array[TradeID]),

    # 
    # ID of the Transaction that cancelled the Order (only provided when the
    # Order’s state is CANCELLED)
    # 
    cancellingTransactionID : (TransactionID),

    # 
    # Date/time when the Order was cancelled (only provided when the state of
    # the Order is CANCELLED)
    # 
    cancelledTime : (DateTime),

    # 
    # The ID of the Order that was replaced by this Order (only provided if
    # this Order was created as part of a cancel/replace).
    # 
    replacesOrderID : (OrderID),

    # 
    # The ID of the Order that replaced this Order (only provided if this Order
    # was cancelled as part of a cancel/replace).
    # 
    replacedByOrderID : (OrderID)
}

Order Requests

The request specification of all Orders supported by the platform. These objects are used by the API client to create Orders on the platform.

MarketOrderRequest is an application/json object with the following Schema:

{
    # 
    # The type of the Order to Create. Must be set to “MARKET” when creating a
    # Market Order.
    # 
    type : (OrderType, default=MARKET),

    # 
    # The Market Order’s Instrument.
    # 
    instrument : (InstrumentName, required),

    # 
    # The quantity requested to be filled by the Market Order. A posititive
    # number of units results in a long Order, and a negative number of units
    # results in a short Order.
    # 
    units : (DecimalNumber, required),

    # 
    # The time-in-force requested for the Market Order. Restricted to FOK or
    # IOC for a MarketOrder.
    # 
    timeInForce : (TimeInForce, required, default=FOK),

    # 
    # The worst price that the client is willing to have the Market Order
    # filled at.
    # 
    priceBound : (PriceValue),

    # 
    # Specification of how Positions in the Account are modified when the Order
    # is filled.
    # 
    positionFill : (OrderPositionFill, required, default=DEFAULT),

    # 
    # The client extensions to add to the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # TakeProfitDetails specifies the details of a Take Profit Order to be
    # created on behalf of a client. This may happen when an Order is filled
    # that opens a Trade requiring a Take Profit, or when a Trade’s dependent
    # Take Profit Order is modified directly through the Trade.
    # 
    takeProfitOnFill : (TakeProfitDetails),

    # 
    # StopLossDetails specifies the details of a Stop Loss Order to be created
    # on behalf of a client. This may happen when an Order is filled that opens
    # a Trade requiring a Stop Loss, or when a Trade’s dependent Stop Loss
    # Order is modified directly through the Trade.
    # 
    stopLossOnFill : (StopLossDetails),

    # 
    # TrailingStopLossDetails specifies the details of a Trailing Stop Loss
    # Order to be created on behalf of a client. This may happen when an Order
    # is filled that opens a Trade requiring a Trailing Stop Loss, or when a
    # Trade’s dependent Trailing Stop Loss Order is modified directly through
    # the Trade.
    # 
    trailingStopLossOnFill : (TrailingStopLossDetails),

    # 
    # Client Extensions to add to the Trade created when the Order is filled
    # (if such a Trade is created). Do not set, modify, or delete
    # tradeClientExtensions if your account is associated with MT4.
    # 
    tradeClientExtensions : (ClientExtensions)
}

LimitOrderRequest is an application/json object with the following Schema:

{
    # 
    # The type of the Order to Create. Must be set to “LIMIT” when creating a
    # Market Order.
    # 
    type : (OrderType, default=LIMIT),

    # 
    # The Limit Order’s Instrument.
    # 
    instrument : (InstrumentName, required),

    # 
    # The quantity requested to be filled by the Limit Order. A posititive
    # number of units results in a long Order, and a negative number of units
    # results in a short Order.
    # 
    units : (DecimalNumber, required),

    # 
    # The price threshold specified for the Limit Order. The Limit Order will
    # only be filled by a market price that is equal to or better than this
    # price.
    # 
    price : (PriceValue, required),

    # 
    # The time-in-force requested for the Limit Order.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the Limit Order will be cancelled if its timeInForce
    # is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of how Positions in the Account are modified when the Order
    # is filled.
    # 
    positionFill : (OrderPositionFill, required, default=DEFAULT),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # The client extensions to add to the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # TakeProfitDetails specifies the details of a Take Profit Order to be
    # created on behalf of a client. This may happen when an Order is filled
    # that opens a Trade requiring a Take Profit, or when a Trade’s dependent
    # Take Profit Order is modified directly through the Trade.
    # 
    takeProfitOnFill : (TakeProfitDetails),

    # 
    # StopLossDetails specifies the details of a Stop Loss Order to be created
    # on behalf of a client. This may happen when an Order is filled that opens
    # a Trade requiring a Stop Loss, or when a Trade’s dependent Stop Loss
    # Order is modified directly through the Trade.
    # 
    stopLossOnFill : (StopLossDetails),

    # 
    # TrailingStopLossDetails specifies the details of a Trailing Stop Loss
    # Order to be created on behalf of a client. This may happen when an Order
    # is filled that opens a Trade requiring a Trailing Stop Loss, or when a
    # Trade’s dependent Trailing Stop Loss Order is modified directly through
    # the Trade.
    # 
    trailingStopLossOnFill : (TrailingStopLossDetails),

    # 
    # Client Extensions to add to the Trade created when the Order is filled
    # (if such a Trade is created). Do not set, modify, or delete
    # tradeClientExtensions if your account is associated with MT4.
    # 
    tradeClientExtensions : (ClientExtensions)
}

StopOrderRequest is an application/json object with the following Schema:

{
    # 
    # The type of the Order to Create. Must be set to “STOP” when creating a
    # Stop Order.
    # 
    type : (OrderType, default=STOP),

    # 
    # The Stop Order’s Instrument.
    # 
    instrument : (InstrumentName, required),

    # 
    # The quantity requested to be filled by the Stop Order. A posititive
    # number of units results in a long Order, and a negative number of units
    # results in a short Order.
    # 
    units : (DecimalNumber, required),

    # 
    # The price threshold specified for the Stop Order. The Stop Order will
    # only be filled by a market price that is equal to or worse than this
    # price.
    # 
    price : (PriceValue, required),

    # 
    # The worst market price that may be used to fill this Stop Order. If the
    # market gaps and crosses through both the price and the priceBound, the
    # Stop Order will be cancelled instead of being filled.
    # 
    priceBound : (PriceValue),

    # 
    # The time-in-force requested for the Stop Order.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the Stop Order will be cancelled if its timeInForce is
    # “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of how Positions in the Account are modified when the Order
    # is filled.
    # 
    positionFill : (OrderPositionFill, required, default=DEFAULT),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # The client extensions to add to the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # TakeProfitDetails specifies the details of a Take Profit Order to be
    # created on behalf of a client. This may happen when an Order is filled
    # that opens a Trade requiring a Take Profit, or when a Trade’s dependent
    # Take Profit Order is modified directly through the Trade.
    # 
    takeProfitOnFill : (TakeProfitDetails),

    # 
    # StopLossDetails specifies the details of a Stop Loss Order to be created
    # on behalf of a client. This may happen when an Order is filled that opens
    # a Trade requiring a Stop Loss, or when a Trade’s dependent Stop Loss
    # Order is modified directly through the Trade.
    # 
    stopLossOnFill : (StopLossDetails),

    # 
    # TrailingStopLossDetails specifies the details of a Trailing Stop Loss
    # Order to be created on behalf of a client. This may happen when an Order
    # is filled that opens a Trade requiring a Trailing Stop Loss, or when a
    # Trade’s dependent Trailing Stop Loss Order is modified directly through
    # the Trade.
    # 
    trailingStopLossOnFill : (TrailingStopLossDetails),

    # 
    # Client Extensions to add to the Trade created when the Order is filled
    # (if such a Trade is created). Do not set, modify, or delete
    # tradeClientExtensions if your account is associated with MT4.
    # 
    tradeClientExtensions : (ClientExtensions)
}

MarketIfTouchedOrderRequest is an application/json object with the following Schema:

{
    # 
    # The type of the Order to Create. Must be set to “MARKET_IF_TOUCHED” when
    # creating a Market If Touched Order.
    # 
    type : (OrderType, default=MARKET_IF_TOUCHED),

    # 
    # The MarketIfTouched Order’s Instrument.
    # 
    instrument : (InstrumentName, required),

    # 
    # The quantity requested to be filled by the MarketIfTouched Order. A
    # posititive number of units results in a long Order, and a negative number
    # of units results in a short Order.
    # 
    units : (DecimalNumber, required),

    # 
    # The price threshold specified for the MarketIfTouched Order. The
    # MarketIfTouched Order will only be filled by a market price that crosses
    # this price from the direction of the market price at the time when the
    # Order was created (the initialMarketPrice). Depending on the value of the
    # Order’s price and initialMarketPrice, the MarketIfTouchedOrder will
    # behave like a Limit or a Stop Order.
    # 
    price : (PriceValue, required),

    # 
    # The worst market price that may be used to fill this MarketIfTouched
    # Order.
    # 
    priceBound : (PriceValue),

    # 
    # The time-in-force requested for the MarketIfTouched Order. Restricted to
    # “GTC”, “GFD” and “GTD” for MarketIfTouched Orders.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the MarketIfTouched Order will be cancelled if its
    # timeInForce is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of how Positions in the Account are modified when the Order
    # is filled.
    # 
    positionFill : (OrderPositionFill, required, default=DEFAULT),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # The client extensions to add to the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # TakeProfitDetails specifies the details of a Take Profit Order to be
    # created on behalf of a client. This may happen when an Order is filled
    # that opens a Trade requiring a Take Profit, or when a Trade’s dependent
    # Take Profit Order is modified directly through the Trade.
    # 
    takeProfitOnFill : (TakeProfitDetails),

    # 
    # StopLossDetails specifies the details of a Stop Loss Order to be created
    # on behalf of a client. This may happen when an Order is filled that opens
    # a Trade requiring a Stop Loss, or when a Trade’s dependent Stop Loss
    # Order is modified directly through the Trade.
    # 
    stopLossOnFill : (StopLossDetails),

    # 
    # TrailingStopLossDetails specifies the details of a Trailing Stop Loss
    # Order to be created on behalf of a client. This may happen when an Order
    # is filled that opens a Trade requiring a Trailing Stop Loss, or when a
    # Trade’s dependent Trailing Stop Loss Order is modified directly through
    # the Trade.
    # 
    trailingStopLossOnFill : (TrailingStopLossDetails),

    # 
    # Client Extensions to add to the Trade created when the Order is filled
    # (if such a Trade is created). Do not set, modify, or delete
    # tradeClientExtensions if your account is associated with MT4.
    # 
    tradeClientExtensions : (ClientExtensions)
}

TakeProfitOrderRequest is an application/json object with the following Schema:

{
    # 
    # The type of the Order to Create. Must be set to “TAKE_PROFIT” when
    # creating a Take Profit Order.
    # 
    type : (OrderType, default=TAKE_PROFIT),

    # 
    # The ID of the Trade to close when the price threshold is breached.
    # 
    tradeID : (TradeID, required),

    # 
    # The client ID of the Trade to be closed when the price threshold is
    # breached.
    # 
    clientTradeID : (ClientID),

    # 
    # The price threshold specified for the TakeProfit Order. The associated
    # Trade will be closed by a market price that is equal to or better than
    # this threshold.
    # 
    price : (PriceValue, required),

    # 
    # The time-in-force requested for the TakeProfit Order. Restricted to
    # “GTC”, “GFD” and “GTD” for TakeProfit Orders.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the TakeProfit Order will be cancelled if its
    # timeInForce is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # The client extensions to add to the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions)
}

StopLossOrderRequest is an application/json object with the following Schema:

{
    # 
    # The type of the Order to Create. Must be set to “STOP_LOSS” when creating
    # a Stop Loss Order.
    # 
    type : (OrderType, default=STOP_LOSS),

    # 
    # The ID of the Trade to close when the price threshold is breached.
    # 
    tradeID : (TradeID, required),

    # 
    # The client ID of the Trade to be closed when the price threshold is
    # breached.
    # 
    clientTradeID : (ClientID),

    # 
    # The price threshold specified for the StopLoss Order. The associated
    # Trade will be closed by a market price that is equal to or worse than
    # this threshold.
    # 
    price : (PriceValue, required),

    # 
    # The time-in-force requested for the StopLoss Order. Restricted to “GTC”,
    # “GFD” and “GTD” for StopLoss Orders.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the StopLoss Order will be cancelled if its
    # timeInForce is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # The client extensions to add to the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions)
}

TrailingStopLossOrderRequest is an application/json object with the following Schema:

{
    # 
    # The type of the Order to Create. Must be set to “TRAILING_STOP_LOSS” when
    # creating a Trailng Stop Loss Order.
    # 
    type : (OrderType, default=TRAILING_STOP_LOSS),

    # 
    # The ID of the Trade to close when the price threshold is breached.
    # 
    tradeID : (TradeID, required),

    # 
    # The client ID of the Trade to be closed when the price threshold is
    # breached.
    # 
    clientTradeID : (ClientID),

    # 
    # The price distance specified for the TrailingStopLoss Order.
    # 
    distance : (PriceValue, required),

    # 
    # The time-in-force requested for the TrailingStopLoss Order. Restricted to
    # “GTC”, “GFD” and “GTD” for TrailingStopLoss Orders.
    # 
    timeInForce : (TimeInForce, required, default=GTC),

    # 
    # The date/time when the StopLoss Order will be cancelled if its
    # timeInForce is “GTD”.
    # 
    gtdTime : (DateTime),

    # 
    # Specification of what component of a price should be used for comparison
    # when determining if the Order should be filled.
    # 
    triggerCondition : (OrderTriggerCondition, required, default=DEFAULT),

    # 
    # The client extensions to add to the Order. Do not set, modify, or delete
    # clientExtensions if your account is associated with MT4.
    # 
    clientExtensions : (ClientExtensions)
}

Order-related Definitions

Type string
Format The string representation of the OANDA-assigned OrderID. OANDA-assigned OrderIDs are positive integers, and are derived from the TransactionID of the Transaction that created the Order.
Example 1523

Value Description
MARKET A Market Order
LIMIT A Limit Order
STOP A Stop Order
MARKET_IF_TOUCHED A Market-if-touched Order
TAKE_PROFIT A Take Profit Order
STOP_LOSS A Stop Loss Order
TRAILING_STOP_LOSS A Trailing Stop Loss Order

Value Description
PENDING The Order is currently pending execution
FILLED The Order has been filled
TRIGGERED The Order has been triggered
CANCELLED The Order has been cancelled

OrderIdentifier is an application/json object with the following Schema:

{
    # 
    # The OANDA-assigned Order ID
    # 
    orderID : (OrderID),

    # 
    # The client-provided client Order ID
    # 
    clientOrderID : (ClientID)
}

Type string
Format Either the Order’s OANDA-assigned OrderID or the Order’s client-provided ClientID prefixed by the “@” symbol
Example 1523

Value Description
GTC The Order is “Good unTil Cancelled”
GTD The Order is “Good unTil Date” and will be cancelled at the provided time
GFD The Order is “Good For Day” and will be cancelled at 5pm New York time
FOK The Order must be immediately “Filled Or Killed”
IOC The Order must be “Immediatedly paritally filled Or Cancelled”

Value Description
OPEN_ONLY When the Order is filled, only allow Positions to be opened or extended.
REDUCE_FIRST When the Order is filled, always fully reduce an existing Position before opening a new Position.
REDUCE_ONLY When the Order is filled, only reduce an existing Position.
DEFAULT When the Order is filled, use REDUCE_FIRST behaviour for non-client hedging Accounts, and OPEN_ONLY behaviour for client hedging Accounts.

Value Description
DEFAULT Trigger an Order the “natural” way: compare its price to the ask for long Orders and bid for short Orders.
INVERSE Trigger an Order the opposite of the “natural” way: compare its price the bid for long Orders and ask for short Orders.
BID Trigger an Order by comparing its price to the bid regardless of whether it is long or short.
ASK Trigger an Order by comparing its price to the ask regardless of whether it is long or short.
MID Trigger an Order by comparing its price to the midpoint regardless of whether it is long or short.

DynamicOrderState is an application/json object with the following Schema:

{
    # 
    # The Order’s ID.
    # 
    id : (OrderID),

    # 
    # The Order’s calculated trailing stop value.
    # 
    trailingStopValue : (PriceValue),

    # 
    # The distance between the Trailing Stop Loss Order’s trailingStopValue and
    # the current Market Price. This represents the distance (in price units)
    # of the Order from a triggering price. If the distance could not be
    # determined, this value will not be set.
    # 
    triggerDistance : (PriceValue),

    # 
    # True if an exact trigger distance could be calculated. If false, it means
    # the provided trigger distance is a best estimate. If the distance could
    # not be determined, this value will not be set.
    # 
    isTriggerDistanceExact : (boolean)
}