OanPy: Python Bindings for OANDA Trading API

This open source package provides an extension module for Python that can be used to access to the programmatic API for the OANDA FX broker. The entire API's functionality is supported, including live market data updates and order placement.

The ability to do fast prototyping of trading strategies directly using a dynamic language like Python is very exciting. You can leverage numerical libraries like NumPy in order to perform analysis on market data directly from the API, or you can write custom trading GUIs leveraging toolkits, e.g., PyQt. Our API works in multi-threaded environments, and is compatible with select()/epoll() reactor-based networking libraries (and with Twisted).

How it Works

In order to use these Python bindings, you will need to independently obtain a license to the Linux C++ API from OANDA, and then run a Makefile to build and install your Python extension module, linked with this API.

doc/howitworks.png

Once again, this package does NOT provide the include files nor the binary library that OANDA makes available to its subscribers. You need to obtain this separately (i.e., it costs money).

With it, you will be able to import all of the functionality provided by the OANDA API with a simple import, for example:

# Import the OANDA classes.
from oanda import *

...

# Login to my OANDA account.
fxclient = FXTrade()
try:
    fxclient.login(username, password)
except OAException, e:
    raise SystemExit("Could not login: %s" % e)

# Get my account object.
user = fxclient.getUser()
account = user.getAccounts()[0]

...

# Place a trade.
order = MarketOrder()
order.base, order.quote = 'EUR', 'USD'
order.units = 10000
trades = account.execute(order)
for trade in trades:
    print trade

...

The classes and functions names correspond directly to the documentation that OANDA will provide for your API library. This package's documentation only describes difference between the official API and our mapping into Python.

Source Code

A Mercurial repository can be found at:

http://bitbucket.org/blais/oanpy

Caveats

Some information about the data feed (as of 2009):

Supported Platforms: Linux

Currently, we support only the Linux platform (both Ubuntu 9.04 and Gentoo are known to work).

If you are interested in support for Windows or Mac and are willing to pay for it by the hour, please contact the author.

Licensing

Copyright (C) 2009  Furius Enterprise / 6114750 Canada Inc.
Licensed under the terms of the GNU Lesser General Public License, version 3.
See http://furius.ca/oanpy/LICENSE for details.

Notes:

Author

Can be contacted here.