Oanda’s API python wrapper. Robust and Fast API wrapper for your Forex bot Python library that wraps Oanda API. Built on top of requests, it’s easy to use and makes sense.
Pyoanda is released under the MIT license. The source code is on GitHub and issues are also tracked on GitHub. Works well with python 2.7, 3, 3.1, 3.2, 3.3, 3.4 and pypy.
pip install pyoanda
git clone git@github.com:toloco/pyoanda.git
cd pyoanda
python setup.py install
python setup.py test
from pyoanda import Client, PRACTICE
client = Client(
environment=PRACTICE,
account_id="Your Oanda account ID",
access_token="Your Oanda access token"
)
client.get_instrument_history(
instrument="EUR_GBP",
candle_format="midpoint",
granularity="S30"
)
Note that if you are indenting to use the sandbox environment, you should first use the API to create an account then use the account_id to run the example above.
from pyoanda import Client, SANDBOX
client = Client(environment=SANDBOX)
# Create an account
user = client.create_account()
# Retrieve the username and accountId values for future use
print "username: %s\naccount_id: %d" % (user['username'], user['accountId'])
Check out the examples gallery (Working progress)
Please feel free to send or post new examples! everybody will love to see them.
See Pypi project page.
See Docs project page.