happydasch / btoandav20

Support for Oanda-V20 API in backtrader
Apache License 2.0
131 stars 52 forks source link
backtrader oanda oanda-api oanda-web-trading oandapyv20

btoandav20

Support for Oanda-V20 API in backtrader

This integration is still under development and may have some issues, use it for live trading at your own risk!

What is it

btoandav20 is a package to integrate OANDA into backtrader. It uses the v20 API of OANDA. It can be used with demo or live account. We highly recommend to have a specific account to use backtrader with OANDA. You should not trade manually on the same account if you wish to use backtrader.

It includes all necessary utilities to backtest or do live trading:

Available features:

Order Types

btoandav20 supports Market, Limit and Stop orders. Other order types, like StopTrail need to be created using brackets.

StopTrail order

orderexec: bt.Order.Stop

stopexec: bt.Order.StopTrail

Changing StopTrail order

To change a StopTrail order the stopside or takeside needs to be canceled and a new order with the order type StopTrail needs to be created.

Also an oref of the original order needs to be provided, when creating this order. The order needs to go into the opposing direction.

StopTrail example:

Provide the stoptrail in stopargs with trailamount or trailpercent

Create new trailing stop for parent order

Dependencies

Installation

The following steps have been tested on Mac OS High Sierra and Ubuntu 16 and 18.

  1. Install backtrader pip install backtrader[plotting] (https://www.backtrader.com/docu/installation.html)

  2. Install btoandav20 pip install git+https://github.com/happydasch/btoandav20 or with pipenv install git+https://github.com/happydasch/btoandav20#egg=btoandav20

  3. Import btoandav20 into your script: import btoandav20 (this is considering your script is at the root of your folder)

You can then access the different parts such as:

Live:

Backtesting:

If you encounter an issue during installation, please check this url first: https://community.backtrader.com/topic/1570/oanda-data-feed/ and create a new issue if this doesn't solve it.

Getting Started

See the example folder for more detailed explanation on how to use it.

Contribute

We are looking for contributors: if you are interested to join us please contact us.

Sponsoring

If you want to support the development of btoandav20, consider to support this project.

License

All code is based on backtrader oandastore which is released under GNU General Public License Version 3 by Daniel Rodriguez