Before we start, there are a few parts that we need to set up to get started. I assume you already have a copy of Python installed. If you are new to Python, Continuum Analytics' Anaconda package is great. Just download and install.
We also need an account with Oanda and install an associated package call oandapyV20 to get the example working.
To set up a practice account with Oandas, head to their website and you should see something similar to the following. Select the demo option and you should see the fxTrade Practice account application page.
Once the account has been set up, we need to install the oandapyV20 to play nicely with the Oanda API. You can install oandapyV20 using pip. Copy and paste the following line to your command line / terminal:
pip install oandapyV20
Before we close off this section, there are two more things we need to do. We need the API Key and the Account ID. To obtain the API Key, we to go to Manage API Access under My Services. For Account ID, it can be obtained from Managed Funds. I attached a screehshot below to help you locate these.
When you select Manage API Access, you should be brought to the following screen. Make sure you read the API License Agreement and once you agreed with the terms and conditions, click the Generate button.
You should then come to the following screen with your API Key. Copy it to your clipboard and keep it somewhere safe! Along with the Account ID, these provides almost full access to your Oanda account.
Head back to the main screen and select the Managed Funds button and you should come to the following Summary of Accounts - fxTrade Practice screen. You Account ID is next to the Primary Account Name.