Skip to content

Transaction Models

OANDA Reference: Transaction Data Definitions

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

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.


Base Transaction Models

Transaction

Base transaction information (all transactions inherit these fields).

🔗 OANDA Definition: Transaction

🔗 Source: Transaction

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 | None âž– OANDA request identifier associated with the transaction
type TransactionType ✅ Type of transaction (CREATE, MARKET_ORDER, STOP_LOSS_ORDER, etc.)

TransactionFilter

Query-parameter model implemented as TransactionQueryFilter. This differs from the public TransactionFilter enum, whose values are accepted in endpoint filter lists. The endpoint methods take individual parameters, not this model object.

🔗 Source: TransactionQueryFilter

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

TransactionIDRange

Range of transaction IDs for querying transaction history.

🔗 OANDA Definition: TransactionIDRange

🔗 Source: 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

🔗 Source: 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 | None âž– Guaranteed execution fee charged for the trade in account currency
quote_guaranteed_execution_fee Decimal | None âž– Guaranteed execution fee in quote currency
client_extensions ClientExtensions | None âž– Client-provided metadata for the trade
half_spread_cost AccountUnits | None âž– Half-spread cost for opening the trade in account currency
initial_margin_required AccountUnits | None âž– 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

🔗 Source: 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 | None âž– Realized profit/loss from the reduction in account currency
financing AccountUnits | None âž– Financing charges/credits applied during reduction in account currency
base_financing Decimal | None âž– Financing in base currency
quote_financing Decimal | None âž– Financing in quote currency
financing_rate Decimal | None âž– Financing rate applied
guaranteed_execution_fee AccountUnits | None âž– Guaranteed execution fee charged in account currency
quote_guaranteed_execution_fee Decimal | None âž– Guaranteed execution fee in quote currency
half_spread_cost AccountUnits | None âž– Half-spread cost for closing the trade in account currency

Order Execution Transactions

OrderFillTransaction

Transaction created when an order is filled.

🔗 OANDA Definition: OrderFillTransaction

🔗 Source: OrderFillTransaction

Inherits: All Transaction fields

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

OrderCancelTransaction

Transaction created when an order is cancelled.

🔗 OANDA Definition: OrderCancelTransaction

🔗 Source: OrderCancelTransaction

Inherits: All Transaction fields

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

Order Creation Transactions

MarketOrderTransaction

Transaction created when a Market Order is submitted.

🔗 OANDA Definition: MarketOrderTransaction

🔗 Source: MarketOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
instrument InstrumentName | str ✅ 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 | None âž– Worst acceptable fill price
position_fill OrderPositionFill âž– Position modification behavior
trade_close MarketOrderTradeClose | None âž– Trade close details
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
reason MarketOrderReason | None âž– Reason for creating the market order
client_extensions ClientExtensions | None âž– Client extensions for the order
take_profit_on_fill TakeProfitDetails | None âž– Take profit order creation details
stop_loss_on_fill StopLossDetails | None âž– 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

LimitOrderTransaction

Transaction created when a Limit Order is submitted.

🔗 OANDA Definition: LimitOrderTransaction

🔗 Source: LimitOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
instrument InstrumentName | str ✅ 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 | None âž– Good-till-date expiration timestamp
position_fill OrderPositionFill âž– Position modification behavior
trigger_condition OrderTriggerCondition âž– Price component used for triggering
reason LimitOrderReason | None âž– Reason for creating the limit order
client_extensions ClientExtensions | None âž– Client extensions for the order
take_profit_on_fill TakeProfitDetails | None âž– Take profit order creation details
stop_loss_on_fill StopLossDetails | None âž– 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

StopOrderTransaction

Transaction created when a Stop Order is submitted.

🔗 OANDA Definition: StopOrderTransaction

🔗 Source: StopOrderTransaction

Inherits: All Transaction fields

Field Type Required Description
instrument InstrumentName | str ✅ Trading instrument for the order
units Decimal ✅ Number of units to trade
price PriceValue ✅ Stop price threshold
price_bound PriceValue | None âž– Worst acceptable fill price after trigger
time_in_force TimeInForce âž– Order duration policy
gtd_time DateTime | None âž– Good-till-date expiration timestamp
position_fill OrderPositionFill âž– Position modification behavior
trigger_condition OrderTriggerCondition âž– Price component used for triggering
reason StopOrderReason | None âž– Reason for creating the stop order
client_extensions ClientExtensions | None âž– Client extensions for the order
take_profit_on_fill TakeProfitDetails | None âž– Take profit order creation details
stop_loss_on_fill StopLossDetails | None âž– 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

Specialized Order Transactions

TakeProfitOrderTransaction

Transaction created when a Take Profit Order is submitted.

🔗 OANDA Definition: TakeProfitOrderTransaction

🔗 Source: TakeProfitOrderTransaction

Inherits: All Transaction fields

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

StopLossOrderTransaction

Transaction created when a Stop Loss Order is submitted.

🔗 OANDA Definition: StopLossOrderTransaction

🔗 Source: StopLossOrderTransaction

Inherits: All Transaction fields

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

TrailingStopLossOrderTransaction

Transaction created when a Trailing Stop Loss Order is submitted.

🔗 OANDA Definition: TrailingStopLossOrderTransaction

🔗 Source: TrailingStopLossOrderTransaction

Inherits: All Transaction fields

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