Skip to content

Transaction Models

OANDA Reference: Transaction Data Definitions

Models for transaction history, order fills, and account activity tracking.


Base Transaction Models

Transaction

Base transaction information (all transactions inherit these fields).

Field Type Required Description
id TransactionID Transaction's identifier (positive integer assigned sequentially by OANDA)
time DateTime Date/time when the transaction occurred
user_id int User ID of the user that initiated the transaction
account_id AccountID Account identifier for the account the transaction affects
batch_id TransactionID Transaction batch identifier for grouping related transactions
request_id RequestID Client-provided request identifier for correlating API requests with transactions
type TransactionType Type of transaction (CREATE, MARKET_ORDER, STOP_LOSS_ORDER, etc.)

TransactionFilter

Filter criteria for transaction queries.

Field Type Required Description
from_ str Starting transaction ID for filtering
to str Ending transaction ID for filtering
page_size int Maximum number of transactions to return
type_filter list[TransactionType] Transaction types to include in results

TransactionIDRange

Range of transaction IDs for querying transaction history.

🔗 OANDA Definition: TransactionIDRange

Field Type Required Description
from_ str Starting transaction ID (inclusive)
to str Ending transaction ID (inclusive)

Supporting Transaction Models

TradeOpen

Details of a new trade created as part of an OrderFill.

🔗 OANDA Definition: TradeOpen

Field Type Required Description
trade_id TradeID Unique identifier for the new trade
units Decimal Number of units in the new trade (positive for long, negative for short)
price PriceValue Average price at which the trade was opened
guaranteed_execution_fee AccountUnits Guaranteed execution fee charged for the trade in account currency
quote_guaranteed_execution_fee Decimal Guaranteed execution fee in quote currency
client_extensions ClientExtensions Client-provided metadata for the trade
half_spread_cost AccountUnits Half-spread cost for opening the trade in account currency
initial_margin_required AccountUnits Initial margin requirement for the trade

TradeReduce

Details of a trade that was reduced or fully closed as part of an OrderFill.

🔗 OANDA Definition: TradeReduce

Field Type Required Description
trade_id TradeID Unique identifier for the reduced/closed trade
units Decimal Number of units reduced from the trade (positive for long, negative for short)
price PriceValue Average price at which the trade was reduced/closed
realized_pl AccountUnits Realized profit/loss from the reduction in account currency
financing AccountUnits Financing charges/credits applied during reduction in account currency
base_financing Decimal Financing in base currency
quote_financing Decimal Financing in quote currency
financing_rate Decimal Financing rate applied
guaranteed_execution_fee AccountUnits Guaranteed execution fee charged in account currency
quote_guaranteed_execution_fee Decimal Guaranteed execution fee in quote currency
half_spread_cost AccountUnits Half-spread cost for closing the trade in account currency

Order Execution Transactions

OrderFillTransaction

Transaction created when an order is filled.

Inherits: All Transaction fields

Field Type Required Description
order_id OrderID ID of the Order that was filled
client_order_id str Client-specified order identifier
instrument InstrumentName Trading instrument for the fill
units Decimal Number of units filled by the order
gain_quote_home_conversion_factor Decimal Conversion factor for gain calculation
loss_quote_home_conversion_factor Decimal Conversion factor for loss calculation
price PriceValue Execution price for the fill
full_vwap PriceValue Volume weighted average price for the fill
full_price FullPrice Complete pricing information including closeout bid/ask
reason str Reason for the order fill
pl Decimal Realized profit/loss from the fill
financing Decimal Financing applied to the fill
commission Decimal Commission charged for the fill
guarantee_execution_fee Decimal Guaranteed execution fee charged
account_balance Decimal Account balance after the fill transaction
trade_opened TradeOpen Details of new trade created by the fill
trades_closed list[TradeReduce] List of trades closed by the fill
trade_reduced TradeReduce Details of trade reduced by the fill
half_spread_cost Decimal Half spread cost for the fill

OrderCancelTransaction

Transaction created when an order is cancelled.

🔗 OANDA Definition: OrderCancelTransaction

Inherits: All Transaction fields

Field Type Required Description
order_id OrderID ID of the Order that was cancelled
client_order_id str Client-specified order identifier
reason str Reason for the order cancellation
replaced_by_order_id OrderID ID of the order that replaced this one

Order Creation Transactions

MarketOrderTransaction

Transaction created when a Market Order is submitted.

🔗 OANDA Definition: MarketOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
instrument InstrumentName Trading instrument for the order
units Decimal Number of units to trade
time_in_force TimeInForce Order duration policy (FOK or IOC only)
price_bound PriceValue Worst acceptable fill price
position_fill OrderPositionFill Position modification behavior
trade_close dict Trade close details
long_position_closeout dict Long position closeout details
short_position_closeout dict Short position closeout details
margin_closeout dict Margin closeout details
delayed_trade_close dict Delayed trade close details
reason str Reason for creating the market order
client_extensions ClientExtensions Client extensions for the order
take_profit_on_fill dict Take profit order creation details
stop_loss_on_fill dict Stop loss order creation details
trailing_stop_loss_on_fill dict Trailing stop loss order creation details
trade_client_extensions ClientExtensions Client extensions for created trades

LimitOrderTransaction

Transaction created when a Limit Order is submitted.

🔗 OANDA Definition: LimitOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
instrument InstrumentName Trading instrument for the order
units Decimal Number of units to trade
price PriceValue Price threshold for order execution
time_in_force TimeInForce Order duration policy
gtd_time DateTime Good-till-date expiration timestamp
position_fill OrderPositionFill Position modification behavior
trigger_condition OrderTriggerCondition Price component used for triggering
reason str Reason for creating the limit order
client_extensions ClientExtensions Client extensions for the order
take_profit_on_fill dict Take profit order creation details
stop_loss_on_fill dict Stop loss order creation details
trailing_stop_loss_on_fill dict Trailing stop loss order creation details
trade_client_extensions ClientExtensions Client extensions for created trades

StopOrderTransaction

Transaction created when a Stop Order is submitted.

🔗 OANDA Definition: StopOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
instrument InstrumentName Trading instrument for the order
units Decimal Number of units to trade
price PriceValue Stop price threshold
price_bound PriceValue Worst acceptable fill price after trigger
time_in_force TimeInForce Order duration policy
gtd_time DateTime Good-till-date expiration timestamp
position_fill OrderPositionFill Position modification behavior
trigger_condition OrderTriggerCondition Price component used for triggering
reason str Reason for creating the stop order
client_extensions ClientExtensions Client extensions for the order
take_profit_on_fill dict Take profit order creation details
stop_loss_on_fill dict Stop loss order creation details
trailing_stop_loss_on_fill dict Trailing stop loss order creation details
trade_client_extensions ClientExtensions Client extensions for created trades

Specialized Order Transactions

TakeProfitOrderTransaction

Transaction created when a Take Profit Order is submitted.

🔗 OANDA Definition: TakeProfitOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
trade_id TradeID Trade to close with take profit order
client_trade_id str Client-provided trade identifier
price PriceValue Take profit trigger price
time_in_force TimeInForce Order duration policy
gtd_time DateTime Good-till-date expiration timestamp
trigger_condition OrderTriggerCondition Price component used for triggering
reason str Reason for creating the take profit order
client_extensions ClientExtensions Client extensions for the order

StopLossOrderTransaction

Transaction created when a Stop Loss Order is submitted.

🔗 OANDA Definition: StopLossOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
trade_id TradeID Trade to close with stop loss order
client_trade_id str Client-provided trade identifier
price PriceValue Stop loss trigger price
distance Decimal Distance from trade price (alternative to price)
time_in_force TimeInForce Order duration policy
gtd_time DateTime Good-till-date expiration timestamp
trigger_condition OrderTriggerCondition Price component used for triggering
guaranteed bool Guaranteed execution flag (default: False)
reason str Reason for creating the stop loss order
client_extensions ClientExtensions Client extensions for the order

TrailingStopLossOrderTransaction

Transaction created when a Trailing Stop Loss Order is submitted.

🔗 OANDA Definition: TrailingStopLossOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
trade_id TradeID Trade to close with trailing stop loss order
client_trade_id str Client-provided trade identifier
distance Decimal Trailing distance from trade price
time_in_force TimeInForce Order duration policy
gtd_time DateTime Good-till-date expiration timestamp
trigger_condition OrderTriggerCondition Price component used for triggering
reason str Reason for creating the trailing stop loss order
client_extensions ClientExtensions Client extensions for the order