Algorithmic trading testing
Oanda API test curl command:
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://api-fxpractice.oanda.com/v3/accounts/{accountID}
Endpoint:
GET /instruments/{instrument}/candles
Description:
Fetch candlestick data for a specific instrument, with optional parameters for granularity and count.
curl --location 'http://localhost:8080/instruments/EUR_USD/candles?granularity=M5&count=15' \
--header 'Content-Type: application/json'
Parameters:
instrument
: The instrument symbol (e.g.,EUR_USD
).granularity
(optional): Candlestick granularity (e.g.,M1
,M5
,H1
). Defaults toM1
.count
(optional): Number of candlesticks to retrieve. Defaults to10
.
Endpoint:
GET /instruments/{instrument}/orderBook
Description:
Fetch the order book for a specific instrument.
curl --location 'http://localhost:8080/instruments/EUR_USD/orderBook' \
--header 'Content-Type: application/json'
Endpoint:
GET /instruments/{instrument}/positionBook
Description:
Fetch the position book for a specific instrument.
curl --location 'http://localhost:8080/instruments/EUR_USD/positionBook' \
--header 'Content-Type: application/json'
Endpoint:
GET /account/{accountId}
Description:
Retrieve detailed information for a specific account.
curl --location 'http://localhost:8080/account/101-001-1234567-001' \
--header 'Content-Type: application/json'
Endpoint:
GET /accounts
Description:
Retrieve a list of all accounts associated with your API token.
curl --location 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json'
Endpoint:
GET /account/{accountId}/instruments
Description:
Retrieve a list of tradable instruments for a specific account.
curl --location 'http://localhost:8080/account/101-001-1234567-001/instruments' \
--header 'Content-Type: application/json'
Endpoint:
GET /account/{accountId}/summary
Description:
Retrieve summary information for a specific account.
curl --location 'http://localhost:8080/account/101-001-1234567-001/summary' \
--header 'Content-Type: application/json'
Endpoint:
POST /accounts/{accountId}/orders
Description:
Create a new order for a specific account.
curl --location --request POST 'http://localhost:8080/accounts/101-001-1234567-001/orders' \
--header 'Content-Type: application/json' \
--data-raw '{
"instrument": "EUR_USD",
"units": "1000",
"timeInForce": "FOK",
"type": "MARKET",
"positionFill": "DEFAULT"
}'
Endpoint:
GET /accounts/{accountId}/orders
Description:
Retrieve a list of all orders for a specific account.
curl --location 'http://localhost:8080/accounts/101-001-1234567-001/orders' \
--header 'Content-Type: application/json'
Endpoint:
GET /accounts/{accountId}/pendingOrders
Description:
List all pending orders in a specific account.
curl --location 'http://localhost:8080/accounts/101-001-1234567-001/pendingOrders' \
--header 'Content-Type: application/json'
- Replace
{accountId}
with your actual account ID (e.g.,101-001-1234567-001
). - Replace
{instrument}
with the desired instrument symbol (e.g.,EUR_USD
). - Ensure your application is running on
localhost
at port8080
. Adjust the URL if your server is running on a different host or port. - For the Create an Order endpoint, adjust the JSON payload in
--data-raw
according to the order details you wish to submit.
-
List All Accounts:
curl --location 'http://localhost:8080/accounts' \ --header 'Content-Type: application/json'
-
Get Account Summary:
curl --location 'http://localhost:8080/account/{accountId}/summary' \ --header 'Content-Type: application/json'
-
List Tradable Instruments for Account:
curl --location 'http://localhost:8080/account/{accountId}/instruments' \ --header 'Content-Type: application/json'
-
Fetch Candlestick Data for an Instrument:
curl --location 'http://localhost:8080/instruments/{instrument}/candles?granularity=M15&count=20' \ --header 'Content-Type: application/json'
-
Create a Market Order:
curl --location --request POST 'http://localhost:8080/accounts/{accountId}/orders' \ --header 'Content-Type: application/json' \ --data-raw '{ "instrument": "{instrument}", "units": "1000", "timeInForce": "FOK", "type": "MARKET", "positionFill": "DEFAULT" }'
-
List All Orders for Account:
curl --location 'http://localhost:8080/accounts/{accountId}/orders' \ --header 'Content-Type: application/json'
-
List Pending Orders for Account:
curl --location 'http://localhost:8080/accounts/{accountId}/pendingOrders' \ --header 'Content-Type: application/json'