hootnot / oanda-api-v20

OANDA REST-V20 API wrapper. Easy access to OANDA's REST v20 API with oandapyV20 package. Checkout the Jupyter notebooks!
MIT License
397 stars 107 forks source link

AttributeError: 'API' object has no attribute 'get_history' #143

Closed mehedi02 closed 5 years ago

mehedi02 commented 5 years ago

Following code produce AttributeError

import configparser import oandapyV20 as opy import pandas as pd

config = configparser.ConfigParser() config.read('oanda.cfg')

oanda = opy.API(environment='practice', access_token=config['oanda']['access_token'])

data = oanda.get_historyV20(instrument='EUR_USD', start='2016-12-08', end='2016-12-10', granularity='M1')

df = pd.DataFrame(data['candles']).set_index('time')

df.index = pd.DatetimeIndex(df.index)

df.info()

hootnot commented 5 years ago

@mehedi02

it looks like you mixup my library (oandapyV20) and the one of Oanda (v20).

Using oandapyV20 you create request instances and process these using the client (the oanda instance in your example). So instead of your 'data-line' create the request and process it like:

# see: http://developer.oanda.com/rest-live-v20/instrument-ep/
params = { 'from': ...,
 'to': ... ,
 'granularity': 
}
r = instruments.InstrumentsCandles(instrument="EUR_USD", params=params)
oanda.request(r)
print r.response['candles']

take a look at the docs: https://oanda-api-v20.readthedocs.io/en/latest/endpoints/instruments/instrumentlist.html

mehedi02 commented 5 years ago

Thank you for your reply

On Sun, Apr 28, 2019, 2:18 PM Feite Brekeveld notifications@github.com wrote:

@mehedi02 https://github.com/mehedi02

it looks like you mixup my library (oandapyV20) and the one of Oanda (v20).

Using oandapyV20 you create request instances and process these using the client (the oanda instance in your example). So instead of your 'data-line' create the request and process it like:

see: http://developer.oanda.com/rest-live-v20/instrument-ep/

params = { 'from': ..., 'to': ... , 'granularity': } r = instruments.InstrumentsCandles(instrument="EUR_USD", params=params) oanda.request(r) print r.response['candles']

take a look at the docs: https://oanda-api-v20.readthedocs.io/en/latest/endpoints/instruments/instrumentlist.html

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hootnot/oanda-api-v20/issues/143#issuecomment-487356778, or mute the thread https://github.com/notifications/unsubscribe-auth/AJPQNY2ZWI4YSCL7K7R6PJTPSVMVBANCNFSM4HI5TNFA .

hootnot commented 5 years ago

Hi,

Since you were playing with historical data and dataframes you might want to take a look at:

104