In [6]:
import json
import oandapyV20
import oandapyV20.endpoints.instruments as instruments
from exampleauth import exampleauth
accountID, access_token = exampleauth.exampleAuth()
client = oandapyV20.API(access_token=access_token)
instrument = "EUR_USD"
params = {
"from": "2017-01-01T00:00:00Z",
"granularity": "H1",
"count": 10,
}
r = instruments.InstrumentsCandles(instrument=instrument, params=params)
response = client.request(r)
print("Request: {} #candles received: {}".format(r, len(r.response.get('candles'))))
print(json.dumps(response, indent=2))
Request: v3/instruments/EUR_USD/candles #candles received: 9
{
"instrument": "EUR_USD",
"candles": [
{
"volume": 481,
"mid": {
"h": "1.04712",
"c": "1.04662",
"l": "1.04572",
"o": "1.04577"
},
"complete": true,
"time": "2017-01-03T00:00:00.000000000Z"
},
{
"volume": 664,
"mid": {
"h": "1.04808",
"c": "1.04758",
"l": "1.04646",
"o": "1.04665"
},
"complete": true,
"time": "2017-01-03T01:00:00.000000000Z"
},
{
"volume": 392,
"mid": {
"h": "1.04780",
"c": "1.04721",
"l": "1.04709",
"o": "1.04761"
},
"complete": true,
"time": "2017-01-03T02:00:00.000000000Z"
},
{
"volume": 394,
"mid": {
"h": "1.04848",
"c": "1.04848",
"l": "1.04715",
"o": "1.04718"
},
"complete": true,
"time": "2017-01-03T03:00:00.000000000Z"
},
{
"volume": 285,
"mid": {
"h": "1.04898",
"c": "1.04884",
"l": "1.04820",
"o": "1.04852"
},
"complete": true,
"time": "2017-01-03T04:00:00.000000000Z"
},
{
"volume": 250,
"mid": {
"h": "1.04902",
"c": "1.04824",
"l": "1.04816",
"o": "1.04886"
},
"complete": true,
"time": "2017-01-03T05:00:00.000000000Z"
},
{
"volume": 368,
"mid": {
"h": "1.04892",
"c": "1.04882",
"l": "1.04813",
"o": "1.04821"
},
"complete": true,
"time": "2017-01-03T06:00:00.000000000Z"
},
{
"volume": 1639,
"mid": {
"h": "1.04888",
"c": "1.04602",
"l": "1.04536",
"o": "1.04885"
},
"complete": true,
"time": "2017-01-03T07:00:00.000000000Z"
},
{
"volume": 2830,
"mid": {
"h": "1.04658",
"c": "1.04353",
"l": "1.04207",
"o": "1.04606"
},
"complete": true,
"time": "2017-01-03T08:00:00.000000000Z"
}
],
"granularity": "H1"
}
So, that is 9 records? ... that can be fixed by including the parameter includeFirst, see the OANDA documentation for details.
In [8]:
instrument = "EUR_USD"
params = {
"from": "2017-01-01T00:00:00Z",
"granularity": "H1",
"includeFirst": True,
"count": 10,
}
r = instruments.InstrumentsCandles(instrument=instrument, params=params)
response = client.request(r)
print("Request: {} #candles received: {}".format(r, len(r.response.get('candles'))))
print(json.dumps(response, indent=2))
Request: v3/instruments/EUR_USD/candles #candles received: 10
{
"instrument": "EUR_USD",
"candles": [
{
"volume": 974,
"mid": {
"h": "1.04711",
"c": "1.04575",
"l": "1.04567",
"o": "1.04684"
},
"complete": true,
"time": "2017-01-02T23:00:00.000000000Z"
},
{
"volume": 481,
"mid": {
"h": "1.04712",
"c": "1.04662",
"l": "1.04572",
"o": "1.04577"
},
"complete": true,
"time": "2017-01-03T00:00:00.000000000Z"
},
{
"volume": 664,
"mid": {
"h": "1.04808",
"c": "1.04758",
"l": "1.04646",
"o": "1.04665"
},
"complete": true,
"time": "2017-01-03T01:00:00.000000000Z"
},
{
"volume": 392,
"mid": {
"h": "1.04780",
"c": "1.04721",
"l": "1.04709",
"o": "1.04761"
},
"complete": true,
"time": "2017-01-03T02:00:00.000000000Z"
},
{
"volume": 394,
"mid": {
"h": "1.04848",
"c": "1.04848",
"l": "1.04715",
"o": "1.04718"
},
"complete": true,
"time": "2017-01-03T03:00:00.000000000Z"
},
{
"volume": 285,
"mid": {
"h": "1.04898",
"c": "1.04884",
"l": "1.04820",
"o": "1.04852"
},
"complete": true,
"time": "2017-01-03T04:00:00.000000000Z"
},
{
"volume": 250,
"mid": {
"h": "1.04902",
"c": "1.04824",
"l": "1.04816",
"o": "1.04886"
},
"complete": true,
"time": "2017-01-03T05:00:00.000000000Z"
},
{
"volume": 368,
"mid": {
"h": "1.04892",
"c": "1.04882",
"l": "1.04813",
"o": "1.04821"
},
"complete": true,
"time": "2017-01-03T06:00:00.000000000Z"
},
{
"volume": 1639,
"mid": {
"h": "1.04888",
"c": "1.04602",
"l": "1.04536",
"o": "1.04885"
},
"complete": true,
"time": "2017-01-03T07:00:00.000000000Z"
},
{
"volume": 2830,
"mid": {
"h": "1.04658",
"c": "1.04353",
"l": "1.04207",
"o": "1.04606"
},
"complete": true,
"time": "2017-01-03T08:00:00.000000000Z"
}
],
"granularity": "H1"
}
It is likely that you want to retrieve more than 10 records. The OANDA docs say that the default number of records is 500, in case you do not specify. You can specify the number of records to retrieve by using count, with a maximum of 5000. The InstrumentsCandles class enables you to retrieve the records.
Now if you would like to retrieve a lot of history, you have to make consecutive requests. To make this an easy process the oandapyV20 library comes with a so called factory named InstrumentsCandlesFactory.
Using this class you can retrieve all history of an instrument from a certain date. The InstrumentsCandlesFactory acts as a generator generating InstrumentCandles requests until all data is retrieved. The number of requests can be influenced by specifying count. Setting count to 5000 would generate a tenth of the requests vs. the default of 500.
Back to our example: lets make sure we request a lot of data, so we set the granularity to M5 and leave the date at 2017-01-01T00:00:00. The will retrieve all records from that date up to today, because we did not specify the to parameter.
In [13]:
import json
import oandapyV20
import oandapyV20.endpoints.instruments as instruments
from oandapyV20.contrib.factories import InstrumentsCandlesFactory
from exampleauth import exampleauth
accountID, access_token = exampleauth.exampleAuth()
client = oandapyV20.API(access_token=access_token)
instrument = "EUR_USD"
params = {
"from": "2017-01-01T00:00:00Z",
"granularity": "M5",
}
def cnv(r, h):
# get all candles from the response and write them as a record to the filehandle h
for candle in r.get('candles'):
ctime = candle.get('time')[0:19]
try:
rec = "{time},{complete},{o},{h},{l},{c},{v}".format(
time=ctime,
complete=candle['complete'],
o=candle['mid']['o'],
h=candle['mid']['h'],
l=candle['mid']['l'],
c=candle['mid']['c'],
v=candle['volume'],
)
except Exception as e:
print(e, r)
else:
h.write(rec+"\n")
datafile = "/tmp/{}.{}.out".format(instrument, params['granularity'])
with open(datafile, "w") as O:
n = 0
for r in InstrumentsCandlesFactory(instrument=instrument, params=params):
rv = client.request(r)
cnt = len(r.response.get('candles'))
print("REQUEST: {} {} {}, received: {}".format(r, r.__class__.__name__, r.params, cnt))
n += cnt
cnv(r.response, O)
print("Check the datafile: {} under /tmp!, it contains {} records".format(datafile, n))
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-02T17:40:00Z', 'from': '2017-01-01T00:00:00Z', 'granularity': 'M5'}, received: 0
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-04T11:25:00Z', 'from': '2017-01-02T17:45:00Z', 'granularity': 'M5'}, received: 436
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-06T05:10:00Z', 'from': '2017-01-04T11:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-07T22:55:00Z', 'from': '2017-01-06T05:15:00Z', 'granularity': 'M5'}, received: 200
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-09T16:40:00Z', 'from': '2017-01-07T23:00:00Z', 'granularity': 'M5'}, received: 222
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-11T10:25:00Z', 'from': '2017-01-09T16:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-13T04:10:00Z', 'from': '2017-01-11T10:30:00Z', 'granularity': 'M5'}, received: 498
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-14T21:55:00Z', 'from': '2017-01-13T04:15:00Z', 'granularity': 'M5'}, received: 212
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-16T15:40:00Z', 'from': '2017-01-14T22:00:00Z', 'granularity': 'M5'}, received: 211
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-18T09:25:00Z', 'from': '2017-01-16T15:45:00Z', 'granularity': 'M5'}, received: 497
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-20T03:10:00Z', 'from': '2017-01-18T09:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-21T20:55:00Z', 'from': '2017-01-20T03:15:00Z', 'granularity': 'M5'}, received: 224
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-23T14:40:00Z', 'from': '2017-01-21T21:00:00Z', 'granularity': 'M5'}, received: 193
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-25T08:25:00Z', 'from': '2017-01-23T14:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-27T02:10:00Z', 'from': '2017-01-25T08:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-28T19:55:00Z', 'from': '2017-01-27T02:15:00Z', 'granularity': 'M5'}, received: 236
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-01-30T13:40:00Z', 'from': '2017-01-28T20:00:00Z', 'granularity': 'M5'}, received: 187
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-01T07:25:00Z', 'from': '2017-01-30T13:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-03T01:10:00Z', 'from': '2017-02-01T07:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-04T18:55:00Z', 'from': '2017-02-03T01:15:00Z', 'granularity': 'M5'}, received: 248
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-06T12:40:00Z', 'from': '2017-02-04T19:00:00Z', 'granularity': 'M5'}, received: 175
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-08T06:25:00Z', 'from': '2017-02-06T12:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-10T00:10:00Z', 'from': '2017-02-08T06:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-11T17:55:00Z', 'from': '2017-02-10T00:15:00Z', 'granularity': 'M5'}, received: 260
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-13T11:40:00Z', 'from': '2017-02-11T18:00:00Z', 'granularity': 'M5'}, received: 163
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-15T05:25:00Z', 'from': '2017-02-13T11:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-16T23:10:00Z', 'from': '2017-02-15T05:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-18T16:55:00Z', 'from': '2017-02-16T23:15:00Z', 'granularity': 'M5'}, received: 272
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-20T10:40:00Z', 'from': '2017-02-18T17:00:00Z', 'granularity': 'M5'}, received: 151
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-22T04:25:00Z', 'from': '2017-02-20T10:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-23T22:10:00Z', 'from': '2017-02-22T04:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-25T15:55:00Z', 'from': '2017-02-23T22:15:00Z', 'granularity': 'M5'}, received: 284
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-02-27T09:40:00Z', 'from': '2017-02-25T16:00:00Z', 'granularity': 'M5'}, received: 139
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-01T03:25:00Z', 'from': '2017-02-27T09:45:00Z', 'granularity': 'M5'}, received: 498
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-02T21:10:00Z', 'from': '2017-03-01T03:30:00Z', 'granularity': 'M5'}, received: 498
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-04T14:55:00Z', 'from': '2017-03-02T21:15:00Z', 'granularity': 'M5'}, received: 296
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-06T08:40:00Z', 'from': '2017-03-04T15:00:00Z', 'granularity': 'M5'}, received: 127
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-08T02:25:00Z', 'from': '2017-03-06T08:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-09T20:10:00Z', 'from': '2017-03-08T02:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-11T13:55:00Z', 'from': '2017-03-09T20:15:00Z', 'granularity': 'M5'}, received: 308
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-13T07:40:00Z', 'from': '2017-03-11T14:00:00Z', 'granularity': 'M5'}, received: 126
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-15T01:25:00Z', 'from': '2017-03-13T07:45:00Z', 'granularity': 'M5'}, received: 497
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-16T19:10:00Z', 'from': '2017-03-15T01:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-18T12:55:00Z', 'from': '2017-03-16T19:15:00Z', 'granularity': 'M5'}, received: 308
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-20T06:40:00Z', 'from': '2017-03-18T13:00:00Z', 'granularity': 'M5'}, received: 115
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-22T00:25:00Z', 'from': '2017-03-20T06:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-23T18:10:00Z', 'from': '2017-03-22T00:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-25T11:55:00Z', 'from': '2017-03-23T18:15:00Z', 'granularity': 'M5'}, received: 319
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-27T05:40:00Z', 'from': '2017-03-25T12:00:00Z', 'granularity': 'M5'}, received: 103
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-28T23:25:00Z', 'from': '2017-03-27T05:45:00Z', 'granularity': 'M5'}, received: 497
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-03-30T17:10:00Z', 'from': '2017-03-28T23:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-01T10:55:00Z', 'from': '2017-03-30T17:15:00Z', 'granularity': 'M5'}, received: 331
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-03T04:40:00Z', 'from': '2017-04-01T11:00:00Z', 'granularity': 'M5'}, received: 91
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-04T22:25:00Z', 'from': '2017-04-03T04:45:00Z', 'granularity': 'M5'}, received: 497
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-06T16:10:00Z', 'from': '2017-04-04T22:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-08T09:55:00Z', 'from': '2017-04-06T16:15:00Z', 'granularity': 'M5'}, received: 343
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-10T03:40:00Z', 'from': '2017-04-08T10:00:00Z', 'granularity': 'M5'}, received: 79
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-11T21:25:00Z', 'from': '2017-04-10T03:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-13T15:10:00Z', 'from': '2017-04-11T21:30:00Z', 'granularity': 'M5'}, received: 497
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-15T08:55:00Z', 'from': '2017-04-13T15:15:00Z', 'granularity': 'M5'}, received: 352
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-17T02:40:00Z', 'from': '2017-04-15T09:00:00Z', 'granularity': 'M5'}, received: 67
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-18T20:25:00Z', 'from': '2017-04-17T02:45:00Z', 'granularity': 'M5'}, received: 496
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-20T14:10:00Z', 'from': '2017-04-18T20:30:00Z', 'granularity': 'M5'}, received: 497
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-22T07:55:00Z', 'from': '2017-04-20T14:15:00Z', 'granularity': 'M5'}, received: 366
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-24T01:40:00Z', 'from': '2017-04-22T08:00:00Z', 'granularity': 'M5'}, received: 55
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-25T19:25:00Z', 'from': '2017-04-24T01:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-27T13:10:00Z', 'from': '2017-04-25T19:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-04-29T06:55:00Z', 'from': '2017-04-27T13:15:00Z', 'granularity': 'M5'}, received: 379
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-01T00:40:00Z', 'from': '2017-04-29T07:00:00Z', 'granularity': 'M5'}, received: 43
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-02T18:25:00Z', 'from': '2017-05-01T00:45:00Z', 'granularity': 'M5'}, received: 497
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-04T12:10:00Z', 'from': '2017-05-02T18:30:00Z', 'granularity': 'M5'}, received: 496
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-06T05:55:00Z', 'from': '2017-05-04T12:15:00Z', 'granularity': 'M5'}, received: 392
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-07T23:40:00Z', 'from': '2017-05-06T06:00:00Z', 'granularity': 'M5'}, received: 31
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-09T17:25:00Z', 'from': '2017-05-07T23:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-11T11:10:00Z', 'from': '2017-05-09T17:30:00Z', 'granularity': 'M5'}, received: 498
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-13T04:55:00Z', 'from': '2017-05-11T11:15:00Z', 'granularity': 'M5'}, received: 402
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-14T22:40:00Z', 'from': '2017-05-13T05:00:00Z', 'granularity': 'M5'}, received: 19
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-16T16:25:00Z', 'from': '2017-05-14T22:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-18T10:10:00Z', 'from': '2017-05-16T16:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-20T03:55:00Z', 'from': '2017-05-18T10:15:00Z', 'granularity': 'M5'}, received: 416
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-21T21:40:00Z', 'from': '2017-05-20T04:00:00Z', 'granularity': 'M5'}, received: 7
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-23T15:25:00Z', 'from': '2017-05-21T21:45:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-25T09:10:00Z', 'from': '2017-05-23T15:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-27T02:55:00Z', 'from': '2017-05-25T09:15:00Z', 'granularity': 'M5'}, received: 428
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-28T20:40:00Z', 'from': '2017-05-27T03:00:00Z', 'granularity': 'M5'}, received: 0
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-05-30T14:25:00Z', 'from': '2017-05-28T20:45:00Z', 'granularity': 'M5'}, received: 491
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-01T08:10:00Z', 'from': '2017-05-30T14:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-03T01:55:00Z', 'from': '2017-06-01T08:15:00Z', 'granularity': 'M5'}, received: 440
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-04T19:40:00Z', 'from': '2017-06-03T02:00:00Z', 'granularity': 'M5'}, received: 0
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-06T13:25:00Z', 'from': '2017-06-04T19:45:00Z', 'granularity': 'M5'}, received: 483
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-08T07:10:00Z', 'from': '2017-06-06T13:30:00Z', 'granularity': 'M5'}, received: 498
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-10T00:55:00Z', 'from': '2017-06-08T07:15:00Z', 'granularity': 'M5'}, received: 452
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-11T18:40:00Z', 'from': '2017-06-10T01:00:00Z', 'granularity': 'M5'}, received: 0
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-13T12:25:00Z', 'from': '2017-06-11T18:45:00Z', 'granularity': 'M5'}, received: 471
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-15T06:10:00Z', 'from': '2017-06-13T12:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-16T23:55:00Z', 'from': '2017-06-15T06:15:00Z', 'granularity': 'M5'}, received: 464
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-18T17:40:00Z', 'from': '2017-06-17T00:00:00Z', 'granularity': 'M5'}, received: 0
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-20T11:25:00Z', 'from': '2017-06-18T17:45:00Z', 'granularity': 'M5'}, received: 458
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-22T05:10:00Z', 'from': '2017-06-20T11:30:00Z', 'granularity': 'M5'}, received: 495
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-23T22:55:00Z', 'from': '2017-06-22T05:15:00Z', 'granularity': 'M5'}, received: 474
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-25T16:40:00Z', 'from': '2017-06-23T23:00:00Z', 'granularity': 'M5'}, received: 0
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-27T10:25:00Z', 'from': '2017-06-25T16:45:00Z', 'granularity': 'M5'}, received: 444
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-29T04:10:00Z', 'from': '2017-06-27T10:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-06-30T21:55:00Z', 'from': '2017-06-29T04:15:00Z', 'granularity': 'M5'}, received: 488
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-02T15:40:00Z', 'from': '2017-06-30T22:00:00Z', 'granularity': 'M5'}, received: 0
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-04T09:25:00Z', 'from': '2017-07-02T15:45:00Z', 'granularity': 'M5'}, received: 433
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-06T03:10:00Z', 'from': '2017-07-04T09:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-07T20:55:00Z', 'from': '2017-07-06T03:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-09T14:40:00Z', 'from': '2017-07-07T21:00:00Z', 'granularity': 'M5'}, received: 0
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-11T08:25:00Z', 'from': '2017-07-09T14:45:00Z', 'granularity': 'M5'}, received: 422
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-13T02:10:00Z', 'from': '2017-07-11T08:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-14T19:55:00Z', 'from': '2017-07-13T02:15:00Z', 'granularity': 'M5'}, received: 498
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-16T13:40:00Z', 'from': '2017-07-14T20:00:00Z', 'granularity': 'M5'}, received: 11
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-18T07:25:00Z', 'from': '2017-07-16T13:45:00Z', 'granularity': 'M5'}, received: 412
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-20T01:10:00Z', 'from': '2017-07-18T07:30:00Z', 'granularity': 'M5'}, received: 498
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-21T18:55:00Z', 'from': '2017-07-20T01:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-23T12:40:00Z', 'from': '2017-07-21T19:00:00Z', 'granularity': 'M5'}, received: 23
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-25T06:25:00Z', 'from': '2017-07-23T12:45:00Z', 'granularity': 'M5'}, received: 400
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-27T00:10:00Z', 'from': '2017-07-25T06:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-28T17:55:00Z', 'from': '2017-07-27T00:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-07-30T11:40:00Z', 'from': '2017-07-28T18:00:00Z', 'granularity': 'M5'}, received: 35
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-01T05:25:00Z', 'from': '2017-07-30T11:45:00Z', 'granularity': 'M5'}, received: 388
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-02T23:10:00Z', 'from': '2017-08-01T05:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-04T16:55:00Z', 'from': '2017-08-02T23:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-06T10:40:00Z', 'from': '2017-08-04T17:00:00Z', 'granularity': 'M5'}, received: 47
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-08T04:25:00Z', 'from': '2017-08-06T10:45:00Z', 'granularity': 'M5'}, received: 376
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-09T22:10:00Z', 'from': '2017-08-08T04:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-11T15:55:00Z', 'from': '2017-08-09T22:15:00Z', 'granularity': 'M5'}, received: 498
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-13T09:40:00Z', 'from': '2017-08-11T16:00:00Z', 'granularity': 'M5'}, received: 59
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-15T03:25:00Z', 'from': '2017-08-13T09:45:00Z', 'granularity': 'M5'}, received: 364
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-16T21:10:00Z', 'from': '2017-08-15T03:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-18T14:55:00Z', 'from': '2017-08-16T21:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-20T08:40:00Z', 'from': '2017-08-18T15:00:00Z', 'granularity': 'M5'}, received: 71
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-22T02:25:00Z', 'from': '2017-08-20T08:45:00Z', 'granularity': 'M5'}, received: 352
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-23T20:10:00Z', 'from': '2017-08-22T02:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-25T13:55:00Z', 'from': '2017-08-23T20:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-27T07:40:00Z', 'from': '2017-08-25T14:00:00Z', 'granularity': 'M5'}, received: 83
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-29T01:25:00Z', 'from': '2017-08-27T07:45:00Z', 'granularity': 'M5'}, received: 340
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-08-30T19:10:00Z', 'from': '2017-08-29T01:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-01T12:55:00Z', 'from': '2017-08-30T19:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-03T06:40:00Z', 'from': '2017-09-01T13:00:00Z', 'granularity': 'M5'}, received: 95
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-05T00:25:00Z', 'from': '2017-09-03T06:45:00Z', 'granularity': 'M5'}, received: 325
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-06T18:10:00Z', 'from': '2017-09-05T00:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-08T11:55:00Z', 'from': '2017-09-06T18:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-10T05:40:00Z', 'from': '2017-09-08T12:00:00Z', 'granularity': 'M5'}, received: 107
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-11T23:25:00Z', 'from': '2017-09-10T05:45:00Z', 'granularity': 'M5'}, received: 315
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-13T17:10:00Z', 'from': '2017-09-11T23:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-15T10:55:00Z', 'from': '2017-09-13T17:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-17T04:40:00Z', 'from': '2017-09-15T11:00:00Z', 'granularity': 'M5'}, received: 119
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-18T22:25:00Z', 'from': '2017-09-17T04:45:00Z', 'granularity': 'M5'}, received: 303
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-20T16:10:00Z', 'from': '2017-09-18T22:30:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-22T09:55:00Z', 'from': '2017-09-20T16:15:00Z', 'granularity': 'M5'}, received: 499
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-24T03:40:00Z', 'from': '2017-09-22T10:00:00Z', 'granularity': 'M5'}, received: 131
REQUEST: v3/instruments/EUR_USD/candles InstrumentsCandles {'to': '2017-09-24T17:54:30Z', 'from': '2017-09-24T03:45:00Z', 'granularity': 'M5'}, received: 0
Check the datafile: /tmp/EUR_USD.M5.out under /tmp!, it contains 54090 records
All request were made on the default of max. 500 records per request. With a granularity of M5 this means that we have 288 records per day. The algorithm of the factory does not check on weekends or holidays. Therefore some request only return a part of the 500 requested records because there simply are no more records within the specified timespan.
If you want to decrease the number of requests and increase the number of records returned for a request, just specify count as a number higher than 500 and up to max. 5000.
Content source: hootnot/oanda-api-v20
Similar notebooks: