Instrument


In [1]:
import pandas as pd
import oandapyV20
import oandapyV20.endpoints.instruments as instruments
import configparser

In [2]:
config = configparser.ConfigParser()
config.read('config/config.ini')
accountID = config['oanda']['account_id']
access_token = config['oanda']['api_key']

In [3]:
client = oandapyV20.API(access_token=access_token)

In [4]:
params = {
          "count": 5,
          "granularity": "M5"}

In [5]:
r = instruments.InstrumentsCandles(instrument="DE30_EUR",
                                   params=params)

In [6]:
client.request(r)


Out[6]:
{'candles': [{'complete': True,
   'mid': {'c': '11627.5', 'h': '11631.3', 'l': '11625.0', 'o': '11626.8'},
   'time': '2017-01-20T14:55:00.000000000Z',
   'volume': 429},
  {'complete': True,
   'mid': {'c': '11629.5', 'h': '11636.0', 'l': '11625.0', 'o': '11627.3'},
   'time': '2017-01-20T15:00:00.000000000Z',
   'volume': 518},
  {'complete': True,
   'mid': {'c': '11625.5', 'h': '11630.5', 'l': '11624.0', 'o': '11629.8'},
   'time': '2017-01-20T15:05:00.000000000Z',
   'volume': 332},
  {'complete': True,
   'mid': {'c': '11621.0', 'h': '11629.3', 'l': '11619.8', 'o': '11625.3'},
   'time': '2017-01-20T15:10:00.000000000Z',
   'volume': 401},
  {'complete': False,
   'mid': {'c': '11622.5', 'h': '11624.3', 'l': '11619.3', 'o': '11621.1'},
   'time': '2017-01-20T15:15:00.000000000Z',
   'volume': 268}],
 'granularity': 'M5',
 'instrument': 'DE30_EUR'}

In [7]:
print(r.response)


{'instrument': 'DE30_EUR', 'granularity': 'M5', 'candles': [{'time': '2017-01-20T14:55:00.000000000Z', 'mid': {'h': '11631.3', 'l': '11625.0', 'c': '11627.5', 'o': '11626.8'}, 'volume': 429, 'complete': True}, {'time': '2017-01-20T15:00:00.000000000Z', 'mid': {'h': '11636.0', 'l': '11625.0', 'c': '11629.5', 'o': '11627.3'}, 'volume': 518, 'complete': True}, {'time': '2017-01-20T15:05:00.000000000Z', 'mid': {'h': '11630.5', 'l': '11624.0', 'c': '11625.5', 'o': '11629.8'}, 'volume': 332, 'complete': True}, {'time': '2017-01-20T15:10:00.000000000Z', 'mid': {'h': '11629.3', 'l': '11619.8', 'c': '11621.0', 'o': '11625.3'}, 'volume': 401, 'complete': True}, {'time': '2017-01-20T15:15:00.000000000Z', 'mid': {'h': '11624.3', 'l': '11619.3', 'c': '11622.5', 'o': '11621.1'}, 'volume': 268, 'complete': False}]}

In [8]:
r.response['candles']


Out[8]:
[{'complete': True,
  'mid': {'c': '11627.5', 'h': '11631.3', 'l': '11625.0', 'o': '11626.8'},
  'time': '2017-01-20T14:55:00.000000000Z',
  'volume': 429},
 {'complete': True,
  'mid': {'c': '11629.5', 'h': '11636.0', 'l': '11625.0', 'o': '11627.3'},
  'time': '2017-01-20T15:00:00.000000000Z',
  'volume': 518},
 {'complete': True,
  'mid': {'c': '11625.5', 'h': '11630.5', 'l': '11624.0', 'o': '11629.8'},
  'time': '2017-01-20T15:05:00.000000000Z',
  'volume': 332},
 {'complete': True,
  'mid': {'c': '11621.0', 'h': '11629.3', 'l': '11619.8', 'o': '11625.3'},
  'time': '2017-01-20T15:10:00.000000000Z',
  'volume': 401},
 {'complete': False,
  'mid': {'c': '11622.5', 'h': '11624.3', 'l': '11619.3', 'o': '11621.1'},
  'time': '2017-01-20T15:15:00.000000000Z',
  'volume': 268}]