Order Models¶
OANDA Reference: Order Data Definitions
Models for creating, managing, and tracking orders across all order types and lifecycle states.
Field names are Python attributes. Required means required at model construction;
None in the type indicates a nullable value. Defaults and local validation do not
establish server eligibility. See reading model tables.
Order Request Models¶
MarketOrderRequest¶
Request immediate execution subject to the selected fill policy and available liquidity.
🔗 OANDA Definition: MarketOrderRequest
🔗 Source: MarketOrderRequest
| Field | Type | Required | Description |
|---|---|---|---|
type |
OrderType | âž– | Order type identifier (automatically set to MARKET) |
instrument |
InstrumentName | str | ✅ | Trading instrument for the order |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
time_in_force |
TimeInForce | âž– | Order duration policy (restricted to "FOK" or "IOC" for market orders) |
price_bound |
PriceValue | None | âž– | Worst acceptable fill price (slippage protection) |
position_fill |
OrderPositionFill | âž– | How positions are modified when order is filled (OPEN_ONLY, REDUCE_FIRST, REDUCE_ONLY, DEFAULT) |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order (not available for MT4 accounts) |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details to be applied on fill |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details to be applied on fill |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details to be applied on fill |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details to be applied on fill |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for any trades created by this order |
LimitOrderRequest¶
Request to create a limit order (execution at specific price or better).
🔗 OANDA Definition: LimitOrderRequest
🔗 Source: LimitOrderRequest
| Field | Type | Required | Description |
|---|---|---|---|
type |
OrderType | âž– | Order type identifier (automatically set to LIMIT) |
instrument |
InstrumentName | str | ✅ | Trading instrument for the order |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
price |
PriceValue | ✅ | Price threshold for order execution (string, equal to or better price required) |
time_in_force |
TimeInForce | âž– | Order duration policy (GTC, GTD, GFD, FOK, IOC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (required when time_in_force is "GTD") |
position_fill |
OrderPositionFill | âž– | How positions are modified when order is filled |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (DEFAULT, INVERSE, BID, ASK) |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order (not available for MT4 accounts) |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details to be applied on fill |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details to be applied on fill |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details to be applied on fill |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details to be applied on fill |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for any trades created by this order |
StopOrderRequest¶
Request to create a stop order (market order triggered at specific price).
🔗 OANDA Definition: StopOrderRequest
🔗 Source: StopOrderRequest
| Field | Type | Required | Description |
|---|---|---|---|
type |
OrderType | âž– | Order type identifier (automatically set to STOP) |
instrument |
InstrumentName | str | ✅ | Trading instrument for the order |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
price |
PriceValue | ✅ | Stop price threshold (equal to or worse price triggers execution) |
price_bound |
PriceValue | None | âž– | Worst acceptable fill price after trigger to prevent excessive slippage |
time_in_force |
TimeInForce | âž– | Order duration policy |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (required when time_in_force is "GTD") |
position_fill |
OrderPositionFill | âž– | How positions are modified when order is filled |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (DEFAULT, INVERSE, BID, ASK) |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order (not available for MT4 accounts) |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details to be applied on fill |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details to be applied on fill |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details to be applied on fill |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details to be applied on fill |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for any trades created by this order |
TakeProfitOrderRequest¶
Request to create a take profit order linked to an open trade.
🔗 OANDA Definition: TakeProfitOrderRequest
🔗 Source: TakeProfitOrderRequest
| Field | Type | Required | Description |
|---|---|---|---|
type |
OrderType | âž– | Order type identifier (automatically set to TAKE_PROFIT) |
trade_id |
TradeID | ✅ | Trade identifier to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
price |
PriceValue | ✅ | Price threshold for order execution |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (required when time_in_force is "GTD") |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (DEFAULT, INVERSE, BID, ASK) |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order (not available for MT4 accounts) |
StopLossOrderRequest¶
Request to create a stop loss order linked to an open trade.
🔗 OANDA Definition: StopLossOrderRequest
🔗 Source: StopLossOrderRequest
| Field | Type | Required | Description |
|---|---|---|---|
type |
OrderType | âž– | Order type identifier (automatically set to STOP_LOSS) |
trade_id |
TradeID | ✅ | Trade identifier to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
price |
PriceValue | None | âž– | Price threshold for order execution (either price or distance required) |
distance |
Decimal | None | âž– | Distance from current price (either price or distance required) |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (required when time_in_force is "GTD") |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (DEFAULT, INVERSE, BID, ASK) |
guaranteed |
bool | âž– | Guaranteed execution flag |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order (not available for MT4 accounts) |
TrailingStopLossOrderRequest¶
Request to create a trailing stop loss order linked to an open trade.
🔗 OANDA Definition: TrailingStopLossOrderRequest
🔗 Source: TrailingStopLossOrderRequest
| Field | Type | Required | Description |
|---|---|---|---|
type |
OrderType | âž– | Order type identifier (automatically set to TRAILING_STOP_LOSS) |
trade_id |
TradeID | ✅ | Trade identifier to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
distance |
Decimal | ✅ | Trailing distance from current price |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (required when time_in_force is "GTD") |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (DEFAULT, INVERSE, BID, ASK) |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order (not available for MT4 accounts) |
GuaranteedStopLossOrderRequest¶
Request to create a guaranteed stop loss order linked to an open trade.
🔗 OANDA Definition: GuaranteedStopLossOrderRequest
🔗 Source: GuaranteedStopLossOrderRequest
| Field | Type | Required | Description |
|---|---|---|---|
type |
OrderType | âž– | Order type identifier (automatically set to GUARANTEED_STOP_LOSS) |
trade_id |
TradeID | ✅ | Trade identifier to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
price |
PriceValue | None | âž– | Price threshold for order execution (either price or distance required) |
distance |
Decimal | None | âž– | Distance from current price (either price or distance required) |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (required when time_in_force is "GTD") |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (DEFAULT, INVERSE, BID, ASK) |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order (not available for MT4 accounts) |
MarketIfTouchedOrderRequest¶
Request to create a market-if-touched order (market order triggered at specific price).
🔗 OANDA Definition: MarketIfTouchedOrderRequest
🔗 Source: MarketIfTouchedOrderRequest
| Field | Type | Required | Description |
|---|---|---|---|
type |
OrderType | âž– | Order type identifier (automatically set to MARKET_IF_TOUCHED) |
instrument |
InstrumentName | str | ✅ | Trading instrument for the order |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
price |
PriceValue | ✅ | Price threshold that triggers market execution |
price_bound |
PriceValue | None | âž– | Worst acceptable fill price after trigger to prevent excessive slippage |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (required when time_in_force is "GTD") |
position_fill |
OrderPositionFill | âž– | How positions are modified when order is filled |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (DEFAULT, INVERSE, BID, ASK) |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order (not available for MT4 accounts) |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details to be applied on fill |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details to be applied on fill |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details to be applied on fill |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details to be applied on fill |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for any trades created by this order |
Order Response Models¶
MarketOrder¶
Market-order record; inspect its state and related transactions for the actual outcome.
🔗 OANDA Definition: MarketOrder
🔗 Source: MarketOrder
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | ✅ | Order's identifier, unique within Account |
create_time |
DateTime | ✅ | Time when Order was created |
state |
OrderState | ✅ | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "MARKET" (default) |
instrument |
InstrumentName | str | ✅ | Trading instrument |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
time_in_force |
TimeInForce | âž– | Order duration policy |
price_bound |
PriceValue | None | âž– | Worst acceptable fill price |
position_fill |
OrderPositionFill | âž– | Position modification behavior |
trade_close |
MarketOrderTradeClose | None | âž– | Trade close details (conditional) |
long_position_closeout |
MarketOrderPositionCloseout | None | âž– | Long position closeout details |
short_position_closeout |
MarketOrderPositionCloseout | None | âž– | Short position closeout details |
margin_closeout |
MarketOrderMarginCloseout | None | âž– | Margin closeout details |
delayed_trade_close |
MarketOrderDelayedTradeClose | None | âž– | Delayed trade close details |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for any trades created |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
LimitOrder¶
Limit order that executes only at specified price or better.
🔗 OANDA Definition: LimitOrder
🔗 Source: LimitOrder
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | ✅ | Order's identifier, unique within Account |
create_time |
DateTime | ✅ | Time when Order was created |
state |
OrderState | ✅ | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "LIMIT" (default) |
instrument |
InstrumentName | str | ✅ | Trading instrument |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
price |
PriceValue | ✅ | Price threshold for order execution |
time_in_force |
TimeInForce | âž– | Order duration policy |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
position_fill |
OrderPositionFill | âž– | Position modification behavior |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for any trades created |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
replaces_order_id |
OrderID | None | âž– | ID of the order being replaced |
replaced_by_order_id |
OrderID | None | âž– | ID of the order that replaced this one |
StopOrder¶
Stop order that becomes a market order when price threshold is reached.
🔗 OANDA Definition: StopOrder
🔗 Source: StopOrder
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | ✅ | Order's identifier, unique within Account |
create_time |
DateTime | ✅ | Time when Order was created |
state |
OrderState | ✅ | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "STOP" (default) |
instrument |
InstrumentName | str | ✅ | Trading instrument |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
price |
PriceValue | ✅ | Price threshold for order execution |
price_bound |
PriceValue | None | âž– | Worst acceptable fill price |
time_in_force |
TimeInForce | âž– | Order duration policy |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
position_fill |
OrderPositionFill | âž– | Position modification behavior |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for any trades created |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
replaces_order_id |
OrderID | None | âž– | ID of the order being replaced |
replaced_by_order_id |
OrderID | None | âž– | ID of the order that replaced this one |
GuaranteedStopLossOrder¶
Guaranteed stop-loss record linked to a trade. Availability, minimum distances and fees depend on the account and instrument.
🔗 OANDA Definition: GuaranteedStopLossOrder
🔗 Source: GuaranteedStopLossOrder
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | ✅ | Order's identifier, unique within Account |
create_time |
DateTime | ✅ | Time when Order was created |
state |
OrderState | ✅ | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "GUARANTEED_STOP_LOSS" (default) |
trade_id |
TradeID | ✅ | Trade to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
price |
PriceValue | ✅ | Price threshold for order execution |
distance |
Decimal | None | âž– | Distance from current price |
time_in_force |
TimeInForce | âž– | Order duration policy |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering |
guaranteed_execution_premium |
Decimal | None | âž– | Premium charged for guaranteed execution |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
replaces_order_id |
OrderID | None | âž– | ID of the order being replaced |
replaced_by_order_id |
OrderID | None | âž– | ID of the order that replaced this one |
TakeProfitOrder¶
A Take Profit Order linked to an open Trade and created with a price threshold.
🔗 OANDA Definition: TakeProfitOrder
🔗 Source: TakeProfitOrder
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | ✅ | Order's identifier, unique within Account |
create_time |
DateTime | ✅ | Time when Order was created |
state |
OrderState | ✅ | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "TAKE_PROFIT" |
trade_id |
TradeID | ✅ | Trade to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
price |
PriceValue | ✅ | Trigger price |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (default: DEFAULT) |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
replaces_order_id |
OrderID | None | âž– | ID of the order being replaced |
replaced_by_order_id |
OrderID | None | âž– | ID of the order that replaced this one |
StopLossOrder¶
A Stop Loss Order linked to an open Trade and created with a price threshold.
🔗 OANDA Definition: StopLossOrder
🔗 Source: StopLossOrder
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | ✅ | Order's identifier, unique within Account |
create_time |
DateTime | ✅ | Time when Order was created |
state |
OrderState | ✅ | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "STOP_LOSS" |
guaranteed_execution_premium |
Decimal | None | âž– | Premium charged for guaranteed execution (when guaranteed is True) |
trade_id |
TradeID | ✅ | Trade to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
price |
PriceValue | None | âž– | Trigger price |
distance |
Decimal | None | âž– | Distance from current price (alternative to price) |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (default: DEFAULT) |
guaranteed |
bool | âž– | Guaranteed execution flag |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
replaces_order_id |
OrderID | None | âž– | ID of the order being replaced |
replaced_by_order_id |
OrderID | None | âž– | ID of the order that replaced this one |
TrailingStopLossOrder¶
A Trailing Stop Loss Order linked to an open Trade with a dynamic price distance.
🔗 OANDA Definition: TrailingStopLossOrder
🔗 Source: TrailingStopLossOrder
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | ✅ | Order's identifier, unique within Account |
create_time |
DateTime | ✅ | Time when Order was created |
state |
OrderState | ✅ | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "TRAILING_STOP_LOSS" (default) |
trade_id |
TradeID | ✅ | Trade to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
distance |
Decimal | ✅ | Trailing distance |
time_in_force |
TimeInForce | âž– | Order duration policy |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering |
trailing_stop_value |
PriceValue | None | âž– | Current trailing stop price |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
replaces_order_id |
OrderID | None | âž– | ID of the order being replaced |
replaced_by_order_id |
OrderID | None | âž– | ID of the order that replaced this one |
MarketIfTouchedOrder¶
A Market-If-Touched Order created with a price threshold.
🔗 OANDA Definition: MarketIfTouchedOrder
🔗 Source: MarketIfTouchedOrder
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | ✅ | Order's identifier, unique within Account |
create_time |
DateTime | ✅ | Time when Order was created |
state |
OrderState | ✅ | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "MARKET_IF_TOUCHED" |
instrument |
InstrumentName | str | ✅ | Trading instrument |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
price |
PriceValue | ✅ | Trigger price threshold |
price_bound |
PriceValue | None | âž– | Worst acceptable fill price |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
position_fill |
OrderPositionFill | âž– | Position modification behavior (default: DEFAULT) |
trigger_condition |
OrderTriggerCondition | âž– | Price component used for triggering (default: DEFAULT) |
initial_market_price |
PriceValue | None | âž– | Initial market price when order was created |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for created trades |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
replaces_order_id |
OrderID | None | âž– | Replaced order ID |
replaced_by_order_id |
OrderID | None | âž– | Replacing order ID |
FixedPriceOrder¶
A Fixed Price Order filled immediately at specified price.
🔗 OANDA Definition: FixedPriceOrder
Note: Fixed price orders are typically created by OANDA for specific circumstances (e.g., dividend adjustments). They cannot be directly created via API requests.
| Field | Type | Required | Description |
|---|---|---|---|
id |
OrderID | None | âž– | Order's identifier, unique within Account |
create_time |
DateTime | None | âž– | Time when Order was created |
state |
OrderState | None | âž– | Current state of the Order |
client_extensions |
ClientExtensions | None | âž– | Client extensions (not for MT4 accounts) |
type |
OrderType | âž– | Always "FIXED_PRICE" |
instrument |
InstrumentName | str | ✅ | Trading instrument |
units |
Decimal | ✅ | Number of units to trade (positive for long, negative for short) |
price |
PriceValue | ✅ | Exact fill price |
position_fill |
OrderPositionFill | âž– | Position modification behavior (default: DEFAULT) |
trade_state |
str | ✅ | Resulting trade state |
take_profit_on_fill |
TakeProfitDetails | None | âž– | Take profit order creation details |
stop_loss_on_fill |
StopLossDetails | None | âž– | Stop loss order creation details |
guaranteed_stop_loss_on_fill |
GuaranteedStopLossDetails | None | âž– | Guaranteed stop loss order creation details |
trailing_stop_loss_on_fill |
TrailingStopLossDetails | None | âž– | Trailing stop loss order creation details |
trade_client_extensions |
ClientExtensions | None | âž– | Client extensions for created trades |
filling_transaction_id |
TransactionID | None | âž– | Fill transaction ID (when FILLED) |
filled_time |
DateTime | None | âž– | Fill timestamp (when FILLED) |
trade_opened_id |
TradeID | None | âž– | Opened trade ID (when FILLED) |
trade_reduced_id |
TradeID | None | âž– | Reduced trade ID (when FILLED) |
trade_closed_ids |
list[TradeID] | None | âž– | Closed trade IDs (when FILLED) |
cancelling_transaction_id |
TransactionID | None | âž– | Cancel transaction ID (when CANCELLED) |
cancelled_time |
DateTime | None | âž– | Cancel timestamp (when CANCELLED) |
Order Details Models¶
TakeProfitDetails¶
Details for creating a Take Profit Order on fill.
🔗 OANDA Definition: TakeProfitDetails
🔗 Source: TakeProfitDetails
| Field | Type | Required | Description |
|---|---|---|---|
price |
PriceValue | ✅ | Take profit trigger price |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the take profit order |
StopLossDetails¶
Details for creating a Stop Loss Order on fill.
🔗 OANDA Definition: StopLossDetails
🔗 Source: StopLossDetails
| Field | Type | Required | Description |
|---|---|---|---|
price |
PriceValue | None | âž– | Stop loss trigger price (either price or distance required) |
distance |
Decimal | None | âž– | Distance from fill price (either price or distance required) |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
guaranteed |
bool | âž– | Guaranteed execution flag (default: False) |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the stop loss order |
TrailingStopLossDetails¶
Details for creating a Trailing Stop Loss Order on fill.
🔗 OANDA Definition: TrailingStopLossDetails
🔗 Source: TrailingStopLossDetails
| Field | Type | Required | Description |
|---|---|---|---|
distance |
Decimal | ✅ | Trailing distance from fill price |
time_in_force |
TimeInForce | âž– | Order duration policy (default: GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp (when time_in_force is "GTD") |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the trailing stop loss order |
ClientExtensions¶
Client-provided metadata for Orders and Trades.
🔗 OANDA Definition: ClientExtensions
🔗 Source: ClientExtensions
| Field | Type | Required | Description |
|---|---|---|---|
id |
str | None | âž– | Client-provided identifier (max 64 characters) |
tag |
str | None | âž– | Client-provided tag (max 255 characters) |
comment |
str | None | âž– | Client-provided comment (max 255 characters) |
GuaranteedStopLossDetails¶
Details for guaranteed stop loss orders that ensure execution at guaranteed price.
🔗 OANDA Definition: GuaranteedStopLossDetails
🔗 Source: GuaranteedStopLossDetails
| Field | Type | Required | Description |
|---|---|---|---|
distance |
Decimal | None | âž– | Distance from current price to guaranteed stop loss price |
price |
PriceValue | None | âž– | Price threshold for guaranteed stop loss execution |
time_in_force |
TimeInForce | âž– | Order duration policy (defaults to GTC) |
gtd_time |
DateTime | None | âž– | Good-till-date expiration timestamp |
client_extensions |
ClientExtensions | None | âž– | Client extensions for the order |
DynamicOrderState¶
The dynamic state of an order, including current calculations and trigger information.
🔗 OANDA Definition: DynamicOrderState
🔗 Source: DynamicOrderState
| Field | Type | Required | Description |
|---|---|---|---|
id |
str | ✅ | Order identifier |
trailing_stop_value |
PriceValue | None | âž– | Current trailing stop value for trailing stop orders |
trigger_distance |
Decimal | None | âž– | Current trigger distance for distance-based orders |
is_trigger_distance_exact |
bool | None | âž– | Whether the trigger distance is exact or approximate |
Order Support Models¶
MarketOrderTradeClose¶
Details for closing specific trades with market orders.
🔗 OANDA Definition: MarketOrderTradeClose
🔗 Source: MarketOrderTradeClose
| Field | Type | Required | Description |
|---|---|---|---|
trade_id |
TradeID | ✅ | Trade to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
units |
str | ✅ | Number of units to close (ALL or partial amount) |
MarketOrderPositionCloseout¶
Details for position closeout via market order.
🔗 OANDA Definition: MarketOrderPositionCloseout
🔗 Source: MarketOrderPositionCloseout
| Field | Type | Required | Description |
|---|---|---|---|
instrument |
InstrumentName | str | ✅ | Instrument to close position for |
units |
str | ✅ | Number of units to close (ALL or partial amount) |
MarketOrderMarginCloseout¶
Details for margin closeout market order.
🔗 OANDA Definition: MarketOrderMarginCloseout
🔗 Source: MarketOrderMarginCloseout
| Field | Type | Required | Description |
|---|---|---|---|
reason |
MarketOrderMarginCloseoutReason | ✅ | Reason for margin closeout |
MarketOrderDelayedTradeClose¶
Details for delayed trade close market order.
🔗 OANDA Definition: MarketOrderDelayedTradeClose
🔗 Source: MarketOrderDelayedTradeClose
| Field | Type | Required | Description |
|---|---|---|---|
trade_id |
TradeID | ✅ | Trade to close |
client_trade_id |
str | None | âž– | Client-provided trade identifier |
source_transaction_id |
TransactionID | ✅ | Transaction that initiated the delay |