OANDA Setup Guide
Time: 10 minutes | Difficulty: Moderate | Market: Forex Mode: Full automation | API: REST v20 + Streaming API | Docs: developer.oanda.com
This guide wires an OANDA forex bot to the v20 REST and Streaming API using the botwir3 runtime. Configure API credentials, connect to any supported currency pair, and run automated forex trading locally.
Before you start
Verify that automated operation is permitted under OANDA's current terms of service before deploying. botwir3 provides tools for building structured automation. The user is responsible for compliance with the platform's terms and all applicable regulations.
OANDA Terms of Service | Last verified: May 2026
What you need
- An OANDA account (practice or live — practice accounts are free with virtual funds)
- An API access token generated from the OANDA hub
- The botwir3 runtime downloaded and unzipped
- A strategy config file from the builder
Step 1: Create API credentials
- Log in to hub.oanda.com
- Navigate to Manage API Access (under My Services or My Account)
- Click Generate to create a personal access token
- Copy the API Token
- Note the Account ID (displayed on the hub dashboard — format: XXX-XXX-XXXXXXX-XXX)
Permissions required: The API token grants full trading access to the associated account. There is no granular permission system — the token has the same access as the account holder. Permissions to disable: N/A. Use a practice account for testing to avoid exposure to live funds.
🔒 Security. The OANDA API token grants full account access including trading and position management. Withdrawal is not available through the API. Use a practice account for testing — practice tokens work identically to live tokens with virtual funds.
Step 2: Configure the adapter
Create adapter.json in the bot directory:
{
"adapter": "oanda",
"credentials": {
"api_token": "paste-api-token-here",
"account_id": "XXX-XXX-XXXXXXX-XXX"
},
"trading_pair": "EUR_USD",
"environment": "practice",
"rate_limit_ms": 500
}
Common currency pairs: EUR_USD, GBP_USD, USD_JPY, AUD_USD, USD_CAD. OANDA uses underscore-separated pair notation.
To switch from practice to live trading, change environment to "live" and use a live account API token.
API keys are stored in a local config file on the machine running the bot. They are not transmitted to botwir3 or any third party. botwir3 never sees, stores, or has access to platform credentials.
Step 3: Test the connection
botwir3 test --adapter oanda
Expected output:
[botwir3] Adapter: oanda
[botwir3] Connection: OK
[botwir3] Account: XXX-XXX-XXXXXXX-XXX (practice)
[botwir3] Rate limit: 120 requests/second
Step 4: Start the bot
botwir3 start --config my-strategy.json
The runtime loads the strategy, computes the spec hash, connects to OANDA via the local API token, and begins evaluating signals. The gate function compares proposed actions against the configured spec. The user is responsible for monitoring the bot and verifying execution outcomes.
Rate limits and considerations
| Endpoint | Limit | Notes |
|---|---|---|
| REST API | 120 requests/second | Per connection. Applies to all endpoints. |
| Streaming API | Per connection | Real-time price streaming. One stream per instrument. |
| Order placement | Included in REST limit | No separate order rate limit. |
ℹ Forex hours. The forex market operates 24 hours/day, 5 days/week (Sunday 5 PM ET to Friday 5 PM ET). The bot can run continuously during market hours. Spreads widen during low-liquidity periods (Friday close, Sunday open, major holidays).
Leverage. OANDA offers leverage up to 50:1 for major pairs (US accounts) and higher in other jurisdictions. Leverage amplifies both gains and losses. The user is responsible for configuring position sizing and risk constraints in the strategy.
Common OANDA bot configurations include trend-following on major pairs (EUR_USD, GBP_USD), mean reversion on range-bound crosses (EUR_GBP, AUD_NZD), and carry trade strategies on high-differential pairs. Practice accounts mirror live conditions — strategies can run on practice indefinitely before switching to live. All actions and decisions are recorded in the local ledger.
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
CONNECTION_REFUSED | API token invalid or expired | Regenerate the API token in OANDA Hub |
RATE_LIMITED | Exceeded 120 requests/second | Increase rate_limit_ms in adapter config |
ACCOUNT_NOT_FOUND | Account ID incorrect or token does not match account | Verify account_id in adapter config matches the OANDA Hub dashboard |
INSUFFICIENT_MARGIN | Margin requirement exceeds available funds | Reduce position size or add funds to the account |
MANDATE_INTEGRITY_VIOLATION | Config file modified while bot is running | Stop the bot, verify config, restart |
Related guides
- MetaTrader 4/5 Setup Guide — forex, Expert Advisors, multi-broker
- FXCM Setup Guide — forex, REST + FIX protocol
- TradingView Webhooks Setup Guide — route TradingView alerts to any adapter
One bot. $129. No subscription. No $749/mo platform. → Build for OANDA