Collect historical prices with Oanda API
In this article, I will show how to collect historical currency quotes using Oanda API — forex broker.
First I will cover topic of registration and generate API credentials. To obtain historical data in format, that I woud like to apply in my backtester class, it is necessary to prepare a class to collect and convert data from Oanda.
Demo account in Oanda.
To create demo account you have to visit Oanda website. For register, click “Try demo”. I just want to notice that all steps described below works if you are connect with IP from country where Oanda offers its services.
Next, fill the registration form and login into account. First, find your account id, it should be in main panel with account details. Save the account id for later.
Now change the view to trading mode.
In left panel click “API” — there is link to webpage, where you can generate your API key. Don’t forget to save the key. To connect with API, account id and API key will be required.
Prepare credentials file.
When account is created, and you have account id and API key, just create oanda.cfg file, that should looks like this.