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
402 stars 107 forks source link

Jupyter exampleAuth error #96

Closed alexismanalo closed 7 years ago

alexismanalo commented 7 years ago

I'm getting an error in this line of code under accounts.ipynb

import json
import oandapyV20
import oandapyV20.endpoints.accounts as accounts
from exampleauth import exampleauth

accountID, access_token = exampleauth.exampleAuth()
client = oandapyV20.API(access_token=access_token)

r = accounts.AccountList()
response = client.request(r)
print(json.dumps(response, indent=2))

ModuleNotFoundError Traceback (most recent call last)

in () 2 import oandapyV20 3 import oandapyV20.endpoints.accounts as accounts ----> 4 from exampleauth import exampleauth 5 6 accountID, access_token = exampleauth.exampleAuth() ModuleNotFoundError: No module named 'exampleauth'
hootnot commented 7 years ago

Hi,

that class is in the oandapyV20-examples repo. I will take a look and see to update code and/or docs.

I remember I left that auth part more or less up to the user. It is also simple to skip and just assign token and account.

But with your experience I guess it is better to offer it complete, so I just added that exampleauth/exampleauth.py to the jupyter directory.

If you update your cloned git repo, things should work. Please make sure you update account.txt and token.txt

Make sure you start jupyter from the jupyter directory. Otherwise it will not know the path to exampleauth unless you specify it by PYTHONPATH

Note: if you run ordercreate call's remember that it is weekend and server responses are different. A market order can't be filled for instance.