Particularly Pertinent Programming Interface¶
Getting the Account Status¶
OANDA’s v20 API is a RESTful service. Meaning that the server only sends the changes to the account, rather then the full account. This is useful, in that it reduces network traffic, but requires addition computation on the client side. As changes sent from the server must be incorporated locally.
This functionality is implemented in the
In order to check the status of the account. Use the await syntax, like so:
async def get_account(): async with OandaClient() as client: return await client.account()
account() method uses the response from
account_changes() to update the local account object.
the response from
account_changes() contains more information
Account specifies. Meaning that some
information contained in the
is lost when updating the account. It has been chosen to only keep
in the account that are currently open.
This is to resemble the behaviour of OANDA’s Web based browser interface
Transaction’s are stored on the
Closing all Trades¶
close_all_trades() method is provided to help facilitate
your risk management policy. async_v20 is intended to be used as an algorithmic trading platform,
which naturally raises concerns of run away losses, to the unbeknown user.
close_all_trades() is intended to help mitigate this concern by allowing
users to programme a global stop loss by which all trades can be terminated.
Users who implement this feature should account for the Two possible outcomes.
- returns (True, closed_trade_responses) - All trades were closed