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

Trade Definitions


Type string
Format The string representation of the OANDA-assigned TradeID. OANDA-assigned TradeIDs are positive integers, and are derived from the TransactionID of the Transaction that opened the Trade.
Example 1523

Value Description
OPEN The Trade is currently open
CLOSED The Trade has been fully closed
CLOSE_WHEN_TRADEABLE The Trade will be closed as soon as the trade’s instrument becomes tradeable

Type string
Format Either the Trade’s OANDA-assigned TradeID or the Trade’s client-provided ClientID prefixed by the “@” symbol
Example @my_trade_id

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

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

    # 
    # The Trade’s Instrument.
    # 
    instrument : (InstrumentName),

    # 
    # The execution price of the Trade.
    # 
    price : (PriceValue),

    # 
    # The date/time when the Trade was opened.
    # 
    openTime : (DateTime),

    # 
    # The current state of the Trade.
    # 
    state : (TradeState),

    # 
    # The initial size of the Trade. Negative values indicate a short Trade,
    # and positive values indicate a long Trade.
    # 
    initialUnits : (DecimalNumber),

    # 
    # The number of units currently open for the Trade. This value is reduced
    # to 0.0 as the Trade is closed.
    # 
    currentUnits : (DecimalNumber),

    # 
    # The total profit/loss realized on the closed portion of the Trade.
    # 
    realizedPL : (AccountUnits),

    # 
    # The unrealized profit/loss on the open portion of the Trade.
    # 
    unrealizedPL : (AccountUnits),

    # 
    # The average closing price of the Trade. Only present if the Trade has
    # been closed or reduced at least once.
    # 
    averageClosePrice : (PriceValue),

    # 
    # The IDs of the Transactions that have closed portions of this Trade.
    # 
    closingTransactionIDs : (Array[TransactionID]),

    # 
    # The financing paid/collected for this Trade.
    # 
    financing : (AccountUnits),

    # 
    # The date/time when the Trade was fully closed. Only provided for Trades
    # whose state is CLOSED.
    # 
    closeTime : (DateTime),

    # 
    # The client extensions of the Trade.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # Full representation of the Trade’s Take Profit Order, only provided if
    # such an Order exists.
    # 
    takeProfitOrder : (TakeProfitOrder),

    # 
    # Full representation of the Trade’s Stop Loss Order, only provided if such
    # an Order exists.
    # 
    stopLossOrder : (StopLossOrder),

    # 
    # Full representation of the Trade’s Trailing Stop Loss Order, only
    # provided if such an Order exists.
    # 
    trailingStopLossOrder : (TrailingStopLossOrder)
}

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

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

    # 
    # The Trade’s Instrument.
    # 
    instrument : (InstrumentName),

    # 
    # The execution price of the Trade.
    # 
    price : (PriceValue),

    # 
    # The date/time when the Trade was opened.
    # 
    openTime : (DateTime),

    # 
    # The current state of the Trade.
    # 
    state : (TradeState),

    # 
    # The initial size of the Trade. Negative values indicate a short Trade,
    # and positive values indicate a long Trade.
    # 
    initialUnits : (DecimalNumber),

    # 
    # The number of units currently open for the Trade. This value is reduced
    # to 0.0 as the Trade is closed.
    # 
    currentUnits : (DecimalNumber),

    # 
    # The total profit/loss realized on the closed portion of the Trade.
    # 
    realizedPL : (AccountUnits),

    # 
    # The unrealized profit/loss on the open portion of the Trade.
    # 
    unrealizedPL : (AccountUnits),

    # 
    # The average closing price of the Trade. Only present if the Trade has
    # been closed or reduced at least once.
    # 
    averageClosePrice : (PriceValue),

    # 
    # The IDs of the Transactions that have closed portions of this Trade.
    # 
    closingTransactionIDs : (Array[TransactionID]),

    # 
    # The financing paid/collected for this Trade.
    # 
    financing : (AccountUnits),

    # 
    # The date/time when the Trade was fully closed. Only provided for Trades
    # whose state is CLOSED.
    # 
    closeTime : (DateTime),

    # 
    # The client extensions of the Trade.
    # 
    clientExtensions : (ClientExtensions),

    # 
    # ID of the Trade’s Take Profit Order, only provided if such an Order
    # exists.
    # 
    takeProfitOrderID : (OrderID),

    # 
    # ID of the Trade’s Stop Loss Order, only provided if such an Order exists.
    # 
    stopLossOrderID : (OrderID),

    # 
    # ID of the Trade’s Trailing Stop Loss Order, only provided if such an
    # Order exists.
    # 
    trailingStopLossOrderID : (OrderID)
}

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

{
    # 
    # The Trade’s ID.
    # 
    id : (TradeID),

    # 
    # The Trade’s unrealized profit/loss.
    # 
    unrealizedPL : (AccountUnits)
}