Before you start
- An OANDA practice (demo) account, free and instant, or an approved live account
- Access to the OANDA Hub (hub.oanda.com)
Create your OANDA API key
- 1
Open a practice account
On oanda.com choose Try a free demo and complete the short form. Practice accounts are created immediately with virtual funds.
- 2
Open the API page in the Hub
Log in to the OANDA Hub, open Tools in the top menu and choose API (labelled Manage API Access in some regions).
- 3
Generate the token
Click Generate. A token appears under Your key to OANDA’s API. Copy the whole string now; OANDA does not keep a copy you can view later.
- 4
Find your account id
Your v20 account id looks like
101-001-1234567-001and is shown in the Hub’s account list (or returned byGET /v3/accounts). Save it asOANDA_ACCOUNT_ID. - 5
Revoke and regenerate when needed
The same page has Revoke. Revoking immediately disables the token everywhere; generate a new one and update your keys.
Test the key
Before wiring the key into a strategy, make one request by hand. It separates “the key is wrong” from “my code is wrong”.
curl -s -H "Authorization: Bearer $OANDA_API_TOKEN" \
https://api-fxpractice.oanda.com/v3/accountsaccounts with ids means the token works. Use api-fxtrade.oanda.com for a live token; 401 means a practice token on the live host or the reverse.Add the key to your AlgoGP project
- 1
Open your project’s APIs & keys tab
Open the strategy project, select APIs & keys, and under Platforms choose OANDA (Pro).
- 2
Paste each value
Paste the values into
OANDA_API_TOKENandOANDA_ACCOUNT_IDand click Save. Values are encrypted at rest, never shown again and never written into code or exports. - 3
Run locally with the same names
Exported projects read the same names from
.env(copy.env.example). Keep.envout of version control.
OANDA_API_TOKEN=paste-your-value-here
OANDA_ACCOUNT_ID=paste-your-value-hereToken safety
- A token grants trading on every account under your login. Treat it like a password.
- Keep live tokens off development machines; use practice tokens there.
- Store it in AlgoGP Keys & secrets or a git-ignored
.env, never in code.
Frequently asked questions
Does the OANDA API token expire?
No, it stays valid until you revoke it or generate a new one. Rotate it periodically anyway.
Why does OANDA say my account is not v20?
Very old accounts may be on the legacy platform. Open a new v20 sub-account in the Hub and use its id.
Build an OANDA trading bot in minutes
Describe the strategy in plain English, backtest it on years of data, then export Python that already talks to OANDA: paper, sandbox and live modes, keys handled for you.
- Generated adapter for OANDA orders and balances
- Backtests with costs, slippage and walk-forward checks
- Paper first; live trading only after you opt in
Free plan, no card required. OANDA is included with Pro.
AlgoGP is not affiliated with OANDA. Menus get renamed from time to time; if a label differs, the official documentation has the current path.