OandaClient API¶
Note
OandaClient will look for OANDA_TOKEN in the enviroment variables if no token is passed
OandaClient¶
-
class
async_v20.OandaClient(token=None, account_id=None, format_order_requests=False, max_transaction_history=100, rest_host='api-fxpractice.oanda.com', rest_port=443, rest_scheme='https', stream_host='stream-fxpractice.oanda.com', stream_port=None, stream_scheme='https', health_host='api-status.oanda.com', health_port=80, health_scheme='http', datetime_format='UNIX', rest_timeout=10, stream_timeout=60, max_requests_per_second=99, max_simultaneous_connections=10, debug=False)[source]¶ Bases:
async_v20.interface.account.AccountInterface,async_v20.interface.instrument.InstrumentInterface,async_v20.interface.order.OrderInterface,async_v20.interface.position.PositionInterface,async_v20.interface.pricing.PricingInterface,async_v20.interface.trade.TradeInterface,async_v20.interface.transaction.TransactionInterface,async_v20.interface.user.UserInterface,async_v20.interface.health.HealthInterfaceCreate an API context for v20 access
Parameters: - token – User generated token from the online account configuration page
- account_id – The account id the client will connect to. If None will default to
the first account number returned by
list_accounts() - format_order_requests – True=Format all OrderRequests
in the context of the orders instrument. False=Do not format OrderRequests,
raise
InvalidOrderRequestfor values outside of allowed range. - max_transaction_history – Maximum past transactions to store
- rest_host – The hostname of the v20 REST server
- rest_port – The port of the v20 REST server
- stream_host – The hostname of the v20 REST server
- stream_port – The port of the v20 REST server
- rest_scheme – The scheme of the connection to rest server.
- stream_scheme – The scheme of the connection to the stream server.
- health_host – The hostname of the health API server
- health_port – The port of the health server
- health_scheme – The scheme of the connection for the health server.
- datetime_format – The format to request when dealing with times
- rest_timeout – The timeout to use when making a polling request with the v20 REST server
- stream_timeout – Period to wait for an new json object during streaming
- max_requests_per_second – Maximum HTTP requests sent per second
- max_simultaneous_connections – Maximum concurrent HTTP requests
- debug – Set to True to log debug messages.
Account¶
-
OandaClient.list_accounts(self)¶ Get a list of all Accounts authorized for the provided token.
Returns: - status [200]
Response(accounts=(AccountProperties, …),)
-
OandaClient.get_account_details(self)¶ Get the full details for a single Account that a client has access to. Full pending Order, open Trade and open Position representations are provided.
Returns: - status [200]
Response(account=Account, lastTransactionID=TransactionID)
-
OandaClient.account_summary(self)¶ Get a summary for a single Account that a client has access to.
Returns: - status [200]
Response(account=AccountSummary, lastTransactionID=TransactionID)
-
OandaClient.account_instruments(self, instruments: Instruments= sentinel)¶ Get the list of tradeable instruments for the given Account. The list of tradeable instruments is dependent on the regulatory division that the Account is located in, thus should be the same for all Accounts owned by a single user.
Parameters: - instruments –
Instruments - of instruments to query specifically. (list) –
Returns: - status [200]
Response(instruments=(Instrument, …), lastTransactionID=TransactionID)
- instruments –
-
OandaClient.configure_account(self, alias: Alias= sentinel, margin_rate: DecimalNumber= sentinel)¶ Set the client-configurable portions of an Account.
Parameters: - alias –
AliasClient-defined alias (name) for the Account - margin_rate –
DecimalNumberThe string representation of a decimal number.
Returns: - status [200]
Response(clientConfigureTransaction=ClientConfigureTransaction, lastTransactionID=TransactionID)- status [400]
Response(clientConfigureRejectTransaction=ClientConfigureRejectTransaction, lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [403]
Response(clientConfigureRejectTransaction=ClientConfigureRejectTransaction, lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- alias –
-
OandaClient.account_changes(self, since_transaction_id: SinceTransactionID= sentinel)¶ Endpoint used to poll an Account for its current state and changes since a specified TransactionID.
Note
OandaClient will supply since_transaction_id if None is provided
Parameters: since_transaction_id – SinceTransactionIDID of the Transaction to get Account changes since.Returns: - status [200]
Response(changes=AccountChanges, state=AccountChangesState, lastTransactionID=TransactionID)
Instrument¶
-
OandaClient.get_candles(self, instrument: InstrumentName, price: PriceComponent=M, granularity: CandlestickGranularity=S5, count: Count= sentinel, from_time: FromTime= sentinel, to_time: ToTime= sentinel, smooth: Smooth=False, include_first_query: IncludeFirstQuery= sentinel, daily_alignment: DailyAlignment=17, alignment_timezone: AlignmentTimezone=America/New_York, weekly_alignment: WeeklyAlignment=Friday)¶ Fetch candlestick data for an instrument.
Parameters: - include_first_query –
IncludeFirstQuery - instrument –
InstrumentNameName of the Instrument - price –
PriceComponentThe Price component(s) to get candlestick data for. Can contain any combination of the characters “M” (midpoint candles) “B” (bid candles) and “A” (ask candles). - granularity –
CandlestickGranularityThe granularity of the candlesticks to fetch - count –
CountThe number of candlesticks to return in the reponse. Count should not be specified if both the start and end parameters are provided, as the time range combined with the graularity will determine the number of candlesticks to return. - from_time –
FromTimeThe start of the time range to fetch candlesticks for. - to_time –
ToTimeThe end of the time range to fetch candlesticks for. - smooth –
SmoothA flag that controls whether the candlestick is “smoothed” or not. A smoothed candlestick uses the previous candle’s close price as its open price, while an unsmoothed candlestick uses the first price from its time range as its open price. - daily_alignment –
DailyAlignmentThe hour of the day (in the specified timezone) to use for granularities that have daily alignments. - alignment_timezone –
AlignmentTimezoneThe timezone to use for the dailyAlignment parameter. Candlesticks with daily alignment will be aligned to the dailyAlignment hour within the alignmentTimezone. - weekly_alignment –
WeeklyAlignmentThe day of the week used for granularities that have weekly alignment.
Returns: - status [200]
Response(instrument=InstrumentName, granularity=CandlestickGranularity, candles=(Candlestick, …),)
- include_first_query –
-
OandaClient.get_order_book(self, instrument: InstrumentName, time: DateTime= sentinel)¶ Fetch a gzip compressed order book for an instrument
Parameters: - instrument –
InstrumentNameName of the Instrument - time –
DateTimeThe time of the snapshot to fetch. If not specified, then the most recent snapshot is fetched
Returns: - instrument –
-
OandaClient.get_position_book(self, instrument: InstrumentName, time: DateTime= sentinel)¶ Fetch a gzip compressed order book for an instrument
Parameters: - instrument –
InstrumentNameName of the Instrument - time –
DateTimeThe time of the snapshot to fetch. If not specified, then the most recent snapshot is fetched
Returns: - status [200]
Response(positionBook=PositionBook)
- instrument –
Order¶
-
OandaClient.post_order(self, order_request: OrderRequest= sentinel)¶ Post an OrderRequest.
Parameters: order_request – OrderRequestor a class derived from OrderRequestReturns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
-
OandaClient.create_order(self, instrument: InstrumentName, units: DecimalNumber, type: OrderType=MARKET, trade_id: TradeID= sentinel, price: PriceValue= sentinel, client_trade_id: ClientID= sentinel, time_in_force: TimeInForce= sentinel, gtd_time: DateTime= sentinel, trigger_condition: OrderTriggerCondition= sentinel, client_extensions: ClientExtensions= sentinel, distance: PriceValue= sentinel, price_bound: PriceValue= sentinel, position_fill: OrderPositionFill= sentinel, take_profit_on_fill: TakeProfitDetails= sentinel, stop_loss_on_fill: StopLossDetails= sentinel, trailing_stop_loss_on_fill: TrailingStopLossDetails= sentinel, trade_client_extensions: ClientExtensions= sentinel)¶ create an OrderRequest
Parameters: - trade_id –
TradeID - price –
PriceValue - type –
OrderType - client_trade_id –
ClientID - time_in_force –
TimeInForce - gtd_time –
DateTime - trigger_condition –
OrderTriggerCondition - client_extensions –
ClientExtensions - distance –
PriceValue - instrument –
InstrumentName - units –
Unit - price_bound –
PriceValue - position_fill –
OrderPositionFill - take_profit_on_fill –
TakeProfitDetails - stop_loss_on_fill –
StopLossDetails - trailing_stop_loss_on_fill –
TrailingStopLossDetails - trade_client_extensions –
ClientExtensions
Returns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- trade_id –
-
OandaClient.list_orders(self, ids: Ids= sentinel, state: OrderStateFilter= sentinel, instrument: InstrumentName= sentinel, count: Count= sentinel, before_id: OrderID= sentinel)¶ Get a list of Orders for an Account
Parameters: - ids –
Idslist of Order IDs to retrieve - state –
OrderStateFilterThe state to filter the requested Orders by - instrument –
InstrumentNameThe instrument to filter the requested orders by - count –
CountThe maximum number of Orders to return - before_id –
OrderIDThe maximum Order ID to return. If not provided the most recent Orders in the Account are returned
Returns: - status [200]
Response(orders=(Order, …), lastTransactionID=TransactionID)
- ids –
-
OandaClient.list_pending_orders(self)¶ List all pending Orders
Returns: - status [200]
Response(orders=(Order, …), lastTransactionID=TransactionID)
-
OandaClient.get_order(self, order_specifier: OrderSpecifier= sentinel)¶ Get details for a single Order
Parameters: order_specifier – OrderSpecifierThe Order SpecifierReturns: - status [200]
Response(order=Order, lastTransactionID=TransactionID)
-
OandaClient.replace_order(self, order_specifier: OrderSpecifier= sentinel, order_request: OrderRequest= sentinel)¶ Replace an Order by simultaneously cancelling it and creating a replacement Order
Parameters: - order_specifier –
OrderSpecifierThe Order Specifier - order_request –
OrderRequestSpecification of the replacing Order
Returns: - status [201]
Response(orderCancelTransaction=OrderCancelTransaction, orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, replacingOrderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderCancelRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- order_specifier –
-
OandaClient.cancel_order(self, order_specifier: OrderSpecifier= sentinel)¶ Cancel a pending Order
Parameters: order_specifier – OrderSpecifierThe Order SpecifierReturns: - status [200]
Response(orderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderCancelRejectTransaction=OrderCancelRejectTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
-
OandaClient.set_client_extensions(self, order_specifier: OrderSpecifier= sentinel, client_extensions: ClientExtensions= sentinel, trade_client_extensions: TradeClientExtensions= sentinel)¶ Update the Client Extensions for an Order . Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Parameters: - order_specifier –
OrderSpecifierThe Order Specifier - client_extensions –
ClientExtensionsThe Client Extensions to update for the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4. - trade_client_extensions –
TradeClientExtensionsThe Client Extensions to update for the Trade created when the Order is filled. Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Returns: - status [200]
Response(orderClientExtensionsModifyTransaction=OrderClientExtensionsModifyTransaction, lastTransactionID=TransactionID, relatedTransactionIDs=(TransactionID, …),)- status [400]
Response(orderClientExtensionsModifyRejectTransaction=OrderClientExtensionsModifyRejectTransaction, lastTransactionID=TransactionID, relatedTransactionIDs=(TransactionID, …), errorCode=str, errorMessage=str)- status [401]
Response(orderClientExtensionsModifyRejectTransaction=OrderClientExtensionsModifyRejectTransaction, lastTransactionID=TransactionID, relatedTransactionIDs=(TransactionID, …), errorCode=str, errorMessage=str)
- order_specifier –
-
OandaClient.market_order(self, instrument: InstrumentName, units: DecimalNumber, time_in_force: TimeInForce=FOK, price_bound: PriceValue= sentinel, position_fill: OrderPositionFill=DEFAULT, client_extensions: ClientExtensions= sentinel, take_profit_on_fill: TakeProfitDetails= sentinel, stop_loss_on_fill: StopLossDetails= sentinel, trailing_stop_loss_on_fill: TrailingStopLossDetails= sentinel, trade_client_extensions: ClientExtensions= sentinel)¶ Create a Market Order Request
Parameters: - instrument –
InstrumentNameThe Market Order’s Instrument. - units –
UnitThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the Market Order. Restricted to FOK or IOC for a MarketOrder. - price_bound –
PriceValueThe worst price that the client is willing to have the Market Order filled at. - position_fill –
OrderPositionFillSpecification of how Positions in the Account are modified when the Order is filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4. - take_profit_on_fill –
TakeProfitDetailsTakeProfitDetails 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. - stop_loss_on_fill –
StopLossDetailsStopLossDetails 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. - trailing_stop_loss_on_fill –
TrailingStopLossDetailsTrailingStopLossDetails 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. - trade_client_extensions –
ClientExtensionsClient 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.
Returns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.limit_order(self, instrument: InstrumentName, units: DecimalNumber, price: PriceValue, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, position_fill: OrderPositionFill=DEFAULT, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel, take_profit_on_fill: TakeProfitDetails= sentinel, stop_loss_on_fill: StopLossDetails= sentinel, trailing_stop_loss_on_fill: TrailingStopLossDetails= sentinel, trade_client_extensions: ClientExtensions= sentinel)¶ Create a Limit Order
Parameters: - instrument –
InstrumentNameThe Limit Order’s Instrument. - units –
UnitThe 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. - price –
PriceValueThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the Limit Order. - gtd_time –
DateTimeThe date/time when the Limit Order will be cancelled if its timeInForce is “GTD”. - position_fill –
OrderPositionFillSpecification of how Positions in the Account are modified when the Order is filled. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4. - take_profit_on_fill –
TakeProfitDetailsTakeProfitDetails 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. - stop_loss_on_fill –
StopLossDetailsStopLossDetails 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. - trailing_stop_loss_on_fill –
TrailingStopLossDetailsTrailingStopLossDetails 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. - trade_client_extensions –
ClientExtensionsClient 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.
Returns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.limit_replace_order(self, instrument: InstrumentName, order_specifier: OrderSpecifier, units: DecimalNumber, price: PriceValue, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, position_fill: OrderPositionFill=DEFAULT, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel, take_profit_on_fill: TakeProfitDetails= sentinel, stop_loss_on_fill: StopLossDetails= sentinel, trailing_stop_loss_on_fill: TrailingStopLossDetails= sentinel, trade_client_extensions: ClientExtensions= sentinel)¶ Replace a pending Limit Order
Parameters: - instrument –
InstrumentNameThe Limit Order’s Instrument. - order_specifier –
OrderSpecifierThe ID of the Limit Order to replace - units –
UnitThe 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. - price –
PriceValueThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the Limit Order. - gtd_time –
DateTimeThe date/time when the Limit Order will be cancelled if its timeInForce is “GTD”. - position_fill –
OrderPositionFillSpecification of how Positions in the Account are modified when the Order is filled. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4. - take_profit_on_fill –
TakeProfitDetailsTakeProfitDetails 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. - stop_loss_on_fill –
StopLossDetailsStopLossDetails 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. - trailing_stop_loss_on_fill –
TrailingStopLossDetailsTrailingStopLossDetails 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. - trade_client_extensions –
ClientExtensionsClient 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.
Returns: - status [201]
Response(orderCancelTransaction=OrderCancelTransaction, orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, replacingOrderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderCancelRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.stop_order(self, instrument: InstrumentName, trade_id: TradeID, price: PriceValue, client_trade_id: ClientID= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel)¶ Create a Stop Order
Parameters: - instrument –
InstrumentNameThe StopOrder’s Instrument. - trade_id –
TradeIDThe ID of the Trade to close when the price threshold is breached. - client_trade_id –
TradeIDThe client ID of the Trade to be closed when the price threshold is breached. - price –
PriceValueThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the StopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for StopLoss Orders. - gtd_time –
DateTimeThe date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Returns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.stop_replace_order(self, instrument: InstrumentName, order_specifier: OrderSpecifier, units: DecimalNumber, price: PriceValue, price_bound: PriceValue= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, position_fill: OrderPositionFill=DEFAULT, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel, take_profit_on_fill: TakeProfitDetails= sentinel, stop_loss_on_fill: StopLossDetails= sentinel, trailing_stop_loss_on_fill: TrailingStopLossDetails= sentinel, trade_client_extensions: ClientExtensions= sentinel)¶ Replace a pending Stop Order
Parameters: - instrument –
InstrumentNameThe Stop Order’s Instrument. - order_specifier –
OrderSpecifierThe ID of the Stop Order to replace - units –
UnitThe 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. - price –
PriceValueThe 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_bound –
PriceValueThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the Stop Order. - gtd_time –
DateTimeThe date/time when the Stop Order will be cancelled if its timeInForce is “GTD”. - position_fill –
OrderPositionFillSpecification of how Positions in the Account are modified when the Order is filled. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4. - take_profit_on_fill –
TakeProfitDetailsTakeProfitDetails 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. - stop_loss_on_fill –
StopLossDetailsStopLossDetails 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. - trailing_stop_loss_on_fill –
TrailingStopLossDetailsTrailingStopLossDetails 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. - trade_client_extensions –
ClientExtensionsClient 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.
Returns: - status [201]
Response(orderCancelTransaction=OrderCancelTransaction, orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, replacingOrderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderCancelRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.market_if_touched_order(self, instrument: InstrumentName, units: DecimalNumber, price: PriceValue, price_bound: PriceValue= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, position_fill: OrderPositionFill=DEFAULT, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel, take_profit_on_fill: TakeProfitDetails= sentinel, stop_loss_on_fill: StopLossDetails= sentinel, trailing_stop_loss_on_fill: TrailingStopLossDetails= sentinel, trade_client_extensions: ClientExtensions= sentinel)¶ Create a market if touched order
Parameters: - instrument –
InstrumentNameThe MarketIfTouched Order’s Instrument. - units –
UnitThe 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. - price –
PriceValueThe 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_bound –
PriceValueThe worst market price that may be used to fill this MarketIfTouched Order. - time_in_force –
TimeInForceThe time-in-force requested for the MarketIfTouched Order. Restricted to “GTC”, “GFD” and “GTD” for MarketIfTouched Orders. - gtd_time –
DateTimeThe date/time when the MarketIfTouched Order will be cancelled if its timeInForce is “GTD”. - position_fill –
OrderPositionFillSpecification of how Positions in the Account are modified when the Order is filled. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4. - take_profit_on_fill –
TakeProfitDetailsTakeProfitDetails 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. - stop_loss_on_fill –
StopLossDetailsStopLossDetails 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. - trailing_stop_loss_on_fill –
TrailingStopLossDetailsTrailingStopLossDetails 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. - trade_client_extensions –
ClientExtensionsClient 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.
Returns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.market_if_touched_replace_order(self, instrument: InstrumentName, order_specifier: OrderSpecifier, units: DecimalNumber, price: PriceValue, price_bound: PriceValue= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, position_fill: OrderPositionFill=DEFAULT, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel, take_profit_on_fill: TakeProfitDetails= sentinel, stop_loss_on_fill: StopLossDetails= sentinel, trailing_stop_loss_on_fill: TrailingStopLossDetails= sentinel, trade_client_extensions: ClientExtensions= sentinel)¶ Replace a pending market if touched order
Parameters: - instrument –
InstrumentNameThe MarketIfTouched Order’s Instrument. - order_specifier –
OrderSpecifierThe ID of the MarketIfTouched Order to replace - units –
UnitThe 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. - price –
PriceValueThe 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_bound –
PriceValueThe worst market price that may be used to fill this MarketIfTouched Order. - time_in_force –
TimeInForceThe time-in-force requested for the MarketIfTouched Order. Restricted to “GTC”, “GFD” and “GTD” for MarketIfTouched Orders. - gtd_time –
DateTimeThe date/time when the MarketIfTouched Order will be cancelled if its timeInForce is “GTD”. - position_fill –
OrderPositionFillSpecification of how Positions in the Account are modified when the Order is filled. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4. - take_profit_on_fill –
TakeProfitDetailsTakeProfitDetails 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. - stop_loss_on_fill –
StopLossDetailsStopLossDetails 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. - trailing_stop_loss_on_fill –
TrailingStopLossDetailsTrailingStopLossDetails 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. - trade_client_extensions –
ClientExtensionsClient 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.
Returns: - status [201]
Response(orderCancelTransaction=OrderCancelTransaction, orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, replacingOrderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderCancelRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.take_profit_order(self, instrument: InstrumentName, trade_id: TradeID, price: PriceValue, client_trade_id: ClientID= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel)¶ Create a take profit order
Parameters: - instrument –
InstrumentNameThe TakeProfitOrder’s Instrument. - trade_id –
TradeIDThe ID of the Trade to close when the price threshold is breached. - client_trade_id –
TradeIDThe client ID of the Trade to be closed when the price threshold is breached. - price –
PriceValueThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the TakeProfit Order. Restricted to “GTC”, “GFD” and “GTD” for TakeProfit Orders. - gtd_time –
DateTimeThe date/time when the TakeProfit Order will be cancelled if its timeInForce is “GTD”. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Returns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.take_profit_replace_order(self, instrument: InstrumentName, order_specifier: OrderSpecifier, trade_id: TradeID, price: PriceValue, client_trade_id: ClientID= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel)¶ Replace a pending take profit order
Parameters: - instrument –
InstrumentNameThe TakeProfitOrder’s Instrument. - order_specifier –
OrderSpecifierThe ID of the Take Profit Order to replace - trade_id –
TradeIDThe ID of the Trade to close when the price threshold is breached. - client_trade_id –
TradeIDThe client ID of the Trade to be closed when the price threshold is breached. - price –
PriceValueThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the TakeProfit Order. Restricted to “GTC”, “GFD” and “GTD” for TakeProfit Orders. - gtd_time –
DateTimeThe date/time when the TakeProfit Order will be cancelled if its timeInForce is “GTD”. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Returns: - status [201]
Response(orderCancelTransaction=OrderCancelTransaction, orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, replacingOrderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderCancelRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.stop_loss_order(self, instrument: InstrumentName, trade_id: TradeID, price: PriceValue, client_trade_id: ClientID= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel)¶ Create a Stop Loss Order
Parameters: - instrument –
InstrumentNameThe StopLossOrder’s Instrument. - trade_id –
TradeIDThe ID of the Trade to close when the price threshold is breached. - client_trade_id –
TradeIDThe client ID of the Trade to be closed when the price threshold is breached. - price –
PriceValueThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the StopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for StopLoss Orders. - gtd_time –
DateTimeThe date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Returns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.stop_loss_replace_order(self, instrument: InstrumentName, order_specifier: OrderSpecifier, trade_id: TradeID, price: PriceValue, client_trade_id: ClientID= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel)¶ Replace a pending Stop Loss Order
Parameters: - instrument –
InstrumentNameThe StopLossOrder’s Instrument. - order_specifier –
OrderSpecifierThe ID of the Stop Loss Order to replace - trade_id –
TradeIDThe ID of the Trade to close when the price threshold is breached. - client_trade_id –
TradeIDThe client ID of the Trade to be closed when the price threshold is breached. - price –
PriceValueThe 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. - time_in_force –
TimeInForceThe time-in-force requested for the StopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for StopLoss Orders. - gtd_time –
DateTimeThe date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Returns: - status [201]
Response(orderCancelTransaction=OrderCancelTransaction, orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, replacingOrderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderCancelRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.trailing_stop_loss_order(self, instrument: InstrumentName, trade_id: TradeID, distance: PriceValue, client_trade_id: ClientID= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel)¶ Create a Trailing Stop Loss Order
Parameters: - instrument –
InstrumentNameThe TrailingStopLossOrder’s Instrument. - trade_id –
TradeIDThe ID of the Trade to close when the price threshold is breached. - client_trade_id –
TradeIDThe client ID of the Trade to be closed when the price threshold is breached. - distance –
PriceValueThe price distance specified for the TrailingStopLoss Order. - time_in_force –
TimeInForceThe time-in-force requested for the TrailingStopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for TrailingStopLoss Orders. - gtd_time –
DateTimeThe date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Returns: - status [201]
Response(orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
-
OandaClient.trailing_stop_loss_replace_order(self, instrument: InstrumentName, order_specifier: OrderSpecifier, trade_id: TradeID, distance: PriceValue, client_trade_id: ClientID= sentinel, time_in_force: TimeInForce=GTC, gtd_time: DateTime= sentinel, trigger_condition: OrderTriggerCondition=DEFAULT, client_extensions: ClientExtensions= sentinel)¶ Replace a pending Trailing Stop Loss Order
Parameters: - instrument –
InstrumentNameThe TrailingStopLossOrder’s Instrument. - order_specifier –
OrderSpecifierThe ID of the Take Profit Order to replace - trade_id –
TradeIDThe ID of the Trade to close when the price threshold is breached. - client_trade_id –
TradeIDThe client ID of the Trade to be closed when the price threshold is breached. - distance –
PriceValueThe price distance specified for the TrailingStopLoss Order. - time_in_force –
TimeInForceThe time-in-force requested for the TrailingStopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for TrailingStopLoss Orders. - gtd_time –
DateTimeThe date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”. - trigger_condition –
OrderTriggerConditionSpecification of what component of a price should be used for comparison when determining if the Order should be filled. - client_extensions –
ClientExtensionsThe client extensions to add to the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Returns: - status [201]
Response(orderCancelTransaction=OrderCancelTransaction, orderCreateTransaction=Transaction, orderFillTransaction=OrderFillTransaction, orderReissueTransaction=Transaction, orderReissueRejectTransaction=Transaction, replacingOrderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(orderCancelRejectTransaction=Transaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
- instrument –
Position¶
-
OandaClient.list_positions(self)¶ List all Positions for an Account. The Positions returned are for every instrument that has had a position during the lifetime of an the Account.
Returns: - status [200]
Response(positions=(Position, …), lastTransactionID=TransactionID)
-
OandaClient.list_open_positions(self)¶ List all open Positions for an Account. An open Position is a Position in an Account that currently has a Trade opened for it.
Returns: - status [200]
Response(positions=(Position, …), lastTransactionID=TransactionID)
-
OandaClient.get_position(self, instrument: InstrumentName= sentinel)¶ Get the details of a single Instrument’s Position in an Account. The Position may by open or not.
Parameters: instrument – InstrumentNameName of the InstrumentReturns: - status [200]
Response(position=Position, lastTransactionID=TransactionID)
-
OandaClient.close_position(self, instrument: InstrumentName= sentinel, long_units: LongUnits= sentinel, long_client_extensions: LongClientExtensions= sentinel, short_units: ShortUnits= sentinel, short_client_extensions: ShortClientExtensions= sentinel)¶ Closeout the open Position for a specific instrument in an Account.
Note
- Either long_units or short_units MUST be specified.
- Do NOT specify ALL for long_units or short_units if there are no units to close.
Parameters: - instrument –
InstrumentNameName of the Instrument - long_units –
LongUnitsIndication of how much of the long Position to closeout. Either the string “ALL”, the string “NONE”, or a DecimalNumber representing how many units of the long position to close using a PositionCloseout MarketOrder. The units specified must always be positive. - long_client_extensions –
LongClientExtensionsThe client extensions to add to the MarketOrder used to close the long position. - short_units –
ShortUnitsIndication of how much of the short Position to closeout. Either the string “ALL”, the string “NONE”, or a DecimalNumber representing how many units of the short position to close using a PositionCloseout MarketOrder. The units specified must always be positive. - short_client_extensions –
ShortClientExtensionsThe client extensions to add to the MarketOrder used to close the short position.
Returns: - status [200]
Response(longOrderCreateTransaction=MarketOrderTransaction, longOrderFillTransaction=OrderFillTransaction, longOrderCancelTransaction=OrderCancelTransaction, shortOrderCreateTransaction=MarketOrderTransaction, shortOrderFillTransaction=OrderFillTransaction, shortOrderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(longOrderRejectTransaction=MarketOrderRejectTransaction, shortOrderRejectTransaction=MarketOrderRejectTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)- status [401]
Response(longOrderRejectTransaction=MarketOrderRejectTransaction, shortOrderRejectTransaction=MarketOrderRejectTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID, errorCode=str, errorMessage=str)
Pricing¶
-
OandaClient.get_pricing(self, instruments: Instruments= sentinel, since: DateTime= sentinel)¶ Get pricing information for a specified list of Instruments within an Account.
Parameters: - instruments –
Instruments - of Instruments to get pricing for. (list) –
- since –
DateTimeDate/Time filter to apply to the returned prices. Only prices with a time later than this filter will be provided.
Returns: - instruments –
-
OandaClient.stream_pricing(self, instruments: Instruments= sentinel, snapshot: Snapshot= sentinel)¶ Get a stream of Account Prices starting from when the request is made. This pricing stream does not include every single price created for the Account, but instead will provide at most 4 prices per second (every 250 milliseconds) for each instrument being requested. If more than one price is created for an instrument during the 250 millisecond window, only the price in effect at the end of the window is sent. This means that during periods of rapid price movement, subscribers to this stream will not be sent every price. Pricing windows for different connections to the price stream are not all aligned in the same way (i.e. they are not all aligned to the top of the second). This means that during periods of rapid price movement, different subscribers may observe different prices depending on their alignment.
Parameters: - instruments –
Instruments - of Instruments to stream Prices for. (list) –
- snapshot –
SnapshotFlag that enables/disables the sending of a pricing snapshot when initially connecting to the stream.
Returns: - status [200]
-
OR
Response(heartbeat=PricingHeartbeat)
- instruments –
Trade¶
-
OandaClient.list_trades(self, ids: Ids= sentinel, state: TradeStateFilter= sentinel, instrument: InstrumentName= sentinel, count: Count= sentinel, trade_id: TradeID= sentinel)¶ Get a list of Trades for an Account
Parameters: - ids –
IdsList of Trade IDs to retrieve. - state –
TradeStateFilterThe state to filter the requested Trades by. - instrument –
InstrumentNameThe instrument to filter the requested Trades by. - count –
CountThe maximum number of Trades to return. - trade_id –
TradeIDThe maximum Trade ID to return. If not provided the most recent Trades in the Account are returned.
Returns: - status [200]
Response(trades=(Trade, …), lastTransactionID=TransactionID)
- ids –
-
OandaClient.list_open_trades(self)¶ Get the list of open Trades for an Account
Returns: - status [200]
Response(trades=(Trade, …), lastTransactionID=TransactionID)
-
OandaClient.get_trade(self, trade_specifier: TradeSpecifier= sentinel)¶ Get the details of a specific Trade in an Account
Parameters: trade_specifier – TradeSpecifierSpecifier for the TradeReturns: - status [200]
Response(trade=Trade, lastTransactionID=TransactionID)
-
OandaClient.close_trade(self, trade_specifier: TradeSpecifier= sentinel, units: Units= sentinel)¶ Close (partially or fully) a specific open Trade in an Account
Parameters: - trade_specifier –
TradeSpecifierSpecifier for the Trade - units –
UnitsIndication of how much of the Trade to close. Either the string “ALL” (indicating that all of the Trade should be closed), or a DecimalNumber representing the number of units of the open Trade to Close using a TradeClose MarketOrder. The units specified must always be positive, and the magnitude of the value cannot exceed the magnitude of the Trade’s open units.
Returns: - status [200]
Response(orderCreateTransaction=MarketOrderTransaction, orderFillTransaction=OrderFillTransaction, orderCancelTransaction=OrderCancelTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(orderRejectTransaction=MarketOrderRejectTransaction, errorCode=str, errorMessage=str)- status [401]
Response(orderRejectTransaction=MarketOrderRejectTransaction, lastTransactionID=TransactionID, relatedTransactionIDs=(TransactionID, …), errorCode=str, errorMessage=str)
- trade_specifier –
-
OandaClient.close_all_trades()[source]¶ Close all open trades
Returns: class`~async_v20.interface.response.Response`, …]) Return type: tuple(bool, [
-
OandaClient.set_client_extensions_trade(self, trade_specifier: TradeSpecifier= sentinel, client_extensions: ClientExtensions= sentinel)¶ Update the Client Extensions for a Trade. Do not add, update, or delete the Client Extensions if your account is associated with MT4.
Parameters: - trade_specifier –
TradeSpecifierSpecifier for the Trade - client_extensions –
ClientExtensionsThe Client Extensions to update the Trade with. Do not add, update, or delete the Client Extensions if your account is associated with MT4.
Returns: - status [200]
Response(tradeClientExtensionsModifyTransaction=TradeClientExtensionsModifyTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(tradeClientExtensionsModifyRejectTransaction=TradeClientExtensionsModifyRejectTransaction, lastTransactionID=TransactionID, relatedTransactionIDs=(TransactionID, …), errorCode=str, errorMessage=str)- status [401]
Response(tradeClientExtensionsModifyRejectTransaction=TradeClientExtensionsModifyRejectTransaction, lastTransactionID=TransactionID, relatedTransactionIDs=(TransactionID, …), errorCode=str, errorMessage=str)
- trade_specifier –
-
OandaClient.set_dependent_orders_trade(self, trade_specifier: TradeSpecifier= sentinel, take_profit: TakeProfitDetails= sentinel, stop_loss: StopLossDetails= sentinel, trailing_stop_loss: TrailingStopLossDetails= sentinel)¶ Create, replace and cancel a Trade’s dependent Orders (Take Profit, Stop Loss and Trailing Stop Loss) through the Trade itself
Parameters: - trade_specifier –
TradeSpecifierSpecifier for the Trade - take_profit –
TakeProfitDetailsThe specification of the Take Profit to create/modify/cancel. If takeProfit is set to null, the Take Profit Order will be cancelled if it exists. If takeProfit is not provided, the existing Take Profit Order will not be modified. If a sub- field of takeProfit is not specified, that field will be set to a default value on create, and be inherited by the replacing order on modify. - stop_loss –
StopLossDetailsThe specification of the Stop Loss to create/modify/cancel. If stopLoss is set to null, the Stop Loss Order will be cancelled if it exists. If stopLoss is not provided, the existing Stop Loss Order will not be modified. If a sub-field of stopLoss is not specified, that field will be set to a default value on create, and be inherited by the replacing order on modify. - trailing_stop_loss –
TrailingStopLossDetailsThe specification of the Trailing Stop Loss to create/modify/cancel. If trailingStopLoss is set to null, the Trailing Stop Loss Order will be cancelled if it exists. If trailingStopLoss is not provided, the existing Trailing Stop Loss Order will not be modified. If a sub-field of trailingStopLoss is not specified, that field will be set to a default value on create, and be inherited by the replacing order on modify.
Returns: - status [200]
Response(takeProfitOrderCancelTransaction=OrderCancelTransaction, takeProfitOrderTransaction=TakeProfitOrderTransaction, takeProfitOrderFillTransaction=OrderFillTransaction, takeProfitOrderCreatedCancelTransaction=OrderCancelTransaction, stopLossOrderCancelTransaction=OrderCancelTransaction, stopLossOrderTransaction=StopLossOrderTransaction, stopLossOrderFillTransaction=OrderFillTransaction, stopLossOrderCreatedCancelTransaction=OrderCancelTransaction, trailingStopLossOrderCancelTransaction=OrderCancelTransaction, trailingStopLossOrderTransaction=TrailingStopLossOrderTransaction, relatedTransactionIDs=(TransactionID, …), lastTransactionID=TransactionID)- status [400]
Response(takeProfitOrderCancelRejectTransaction=OrderCancelRejectTransaction, takeProfitOrderRejectTransaction=TakeProfitOrderRejectTransaction, stopLossOrderCancelRejectTransaction=OrderCancelRejectTransaction, stopLossOrderRejectTransaction=StopLossOrderRejectTransaction, trailingStopLossOrderCancelRejectTransaction=OrderCancelRejectTransaction, trailingStopLossOrderRejectTransaction=TrailingStopLossOrderRejectTransaction, lastTransactionID=TransactionID, relatedTransactionIDs=(TransactionID, …), errorCode=str, errorMessage=str)
- trade_specifier –
Transaction¶
-
OandaClient.list_transactions(self, from_time: FromTime= sentinel, to_time: ToTime= sentinel, page_size: PageSize=100, type_: Type= sentinel)¶ Get a list of Transactions pages that satisfy a time-based Transaction query.
Parameters: - from_time –
FromTimeThe starting time (inclusive) of the time range for the Transactions being queried. - to_time –
ToTimeThe ending time (inclusive) of the time range for the Transactions being queried. - page_size –
PageSizeThe number of Transactions to include in each page of the results. - type –
TypeA filter for restricting the types of Transactions to retrieve.
Returns: - status [200]
Response(from=DateTime, to=DateTime, pageSize=int, type=(TransactionFilter, …), count=int, pages=(str, …), lastTransactionID=TransactionID)
- from_time –
-
OandaClient.get_transaction(self, transaction_id: TransactionID)¶ Get the details of a single Account Transaction.
Parameters: transaction_id – TransactionIDA Transaction IDReturns: - status [200]
Response(transaction=Transaction, lastTransactionID=TransactionID)
-
OandaClient.transaction_range(self, from_transaction: FromTransactionID, to_transaction: ToTransactionID, type_: Type= sentinel)¶ Get a range of Transactions for an Account based on the Transaction IDs.
Parameters: - from_transaction –
FromTransactionIDThe starting Transaction ID (inclusive) to fetch. - to_transaction –
ToTransactionIDThe ending Transaction ID (inclusive) to fetch. - type –
TypeThe filter that restricts the types of Transactions to retrieve.
Returns: - status [200]
Response(transactions=(Transaction, …), lastTransactionID=TransactionID)
- from_transaction –
-
OandaClient.since_transaction(self, transaction_id: TransactionID= sentinel)¶ Get a range of Transactions for an Account starting at (but not including) a provided Transaction ID.
Parameters: transaction_id – TransactionIDThe ID of the last Transaction fetched. This query will return all Transactions newer than the TransactionID.Returns: - status [200]
Response(transactions=(Transaction, …), lastTransactionID=TransactionID)
-
OandaClient.stream_transactions(self)¶ Get a stream of Transactions for an Account starting from when the request is made.
Returns: - status [200]
Response(transaction=Transaction)OR
Response(Heartbeat=TransactionHeartbeat)
User¶
-
OandaClient.get_user_info(self, user_specifier: UserSpecifier)¶ Fetch the user information for the specified user. This endpoint is intended to be used by the user thyself to obtain their own information.
Parameters: user_specifier – UserSpecifierThe User SpecifierReturns: - status [200]
Response(userInfo=UserInfo)
-
OandaClient.get_external_user_info(self, user_specifier: UserSpecifier)¶ Fetch the externally-available user information for the specified user. This endpoint is intended to be used by 3rd parties that have been authorized by a user to view their personal information.
Parameters: user_specifier – UserSpecifierThe User SpecifierReturns: - status [200]
Response(userInfo=UserInfoExternal)
Health¶
-
OandaClient.get_current_event(self, service_id: ServiceID)¶ Get the current event for a service
Parameters: service_id – ServiceIDThe service to get the current event forReturns: - status [200]
Response(Event=Event)
-
OandaClient.get_event(self, service_id: ServiceID, event_sid: EventSid)¶ Get an individual event
Parameters: Returns: - status [200]
Response(Event=Event)
-
OandaClient.get_service(self, service_id: ServiceID)¶ Get a single service
Parameters: service_id – ServiceIDName of the service to getReturns: - status [200]
Response(Service=Service)
-
OandaClient.get_service_list(self, service_list_id: ServiceListID)¶ Get a single service list
Parameters: service_list_id – ServiceListIDThe service list to get.Returns: - status [200]
Response(lists=ServiceList)
-
OandaClient.get_status(self, status_id: StatusID)¶ Get an individual status
Parameters: status_id – StatusIDThe status to getReturns: - status [200]
Response(Status=Status)
-
OandaClient.list_events(self, service_id: ServiceID)¶ List all events for a service
Parameters: service_id – ServiceIDThe service to get events for.Returns: - status [200]
Response(lists=(Event,…))
-
OandaClient.list_images(self)¶ List all status images
Returns: - status [200]
Response(images=(Image, …))
-
OandaClient.list_service_lists(self)¶ List all service lists
Returns: - status [200]
Response(lists=(ServiceList, …))