Skip to main content

A platform to enable automated trading and market analysis with Python on the Oanda brokerage API

Project description

Build Status codecov

Automated Trading Platform that runs on Oanda

This repository is being developed to create a base trading platform to build automated trading strategies on. It is designed to use the Oanda brokerage v20 API. And it's primary purpose is to collect market prices, evaluate them and execute trades whilst monitoring your trading account. It is designed to run on a virtual machine, however it can easily be run from a local terminal too!

For visualising the trades and charting there are free desktop and web based software programs available from Oanda

If you would like more information about the Oanda API architecture used within this repo or have more questions on obtaining your Oanda tokens and credentials, you can view the full Oanda v20 developer documentation here

Current Features

Included test strategies:

This repo is designed as a base platform to build strategies upon. As such, everything functional, but it does not contain any profitable automated algorithms. The strategies included can be used to test everything is working. You can view the included algorithms in the strategies/forex_bots_python folder here.

Included is a simple price printer, a basic order execution bot and a simple RSI execution bot.

Email and text notifications

As part of the functionality, this platform includes automated email notifications sent for each up and down occurrence of the platform. If you wish to enable this, you will need pass those arguments into your config.ini (see below). This also means you will need to configure a gmail account to use an application password to use for the email sending options if you keep those enabled. There are optional Twilio SMS notifications you can configure as well.

Database

The data/marketdata.py module collects and stores the last 60 days of market data. It includes details such as margin rates, average spreads, historic high and lows for all the available trading instruments. It is intended to provide easy access to the data for developing and running trading strategies and for working out the cost of trades and money management strategies. The marketdata.py module runs to build the database the first time the platform is run. It will only run once for a given day.

DB Browser https://sqlitebrowser.org/ is good software for viewing and querying of the database.

Upstream remote

This repository was originally forked and developed from Eric Lingren's version Oanda V20 Platform Public. He has other useful server scripts and backtesting systems that are worth checking out and using in conjunction with this code.

Installation

Written and tested on Python 3.7.4, Not yet tested on other Python versions Tested on Windows, Mac and Linux The list of required dependencies is in requirements.txt

To instal run:

git clone --branch=master https://github.com/ant358/oanda_v20_platform_public.git ant358/oanda_v20_platform_public  

cd ant358/oanda_v20_platform_public

Create a virtual environment and activate it.
for ref: https://docs.python.org/3/tutorial/venv.html

Create a .env file in the oanda_v20_platform_public/ folder and add your account number and token. You can add multiple accounts here e.g. live, practice, different accounts for different strategies etc. The classes in the oanda.py module are setup to default to account=PRACTICE_ACCOUNT and token=PRACTICE_TOKEN, when writing strategies to use different accounts simply pass these as keyword arguments to replace the default ones.
Add .env to your .gitignore to keep your account details local.

PRACTICE_ACCOUNT=XXX-XXX-XXXXXXXX-XXX
PRACTICE_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  
$ pip install -e .
$ pip install -r requirements.txt

Usage:

To start the trading platform in a terminal:

cd oanda_v20_platform
python main.py --bot "rsi_bot" --pair "EUR_USD"
  • change python to python3 on linux

Additional Config settings

The arguments listed above are all required for operation but there are optional ones available also for email and sms notifications. To view the full list of all arguments the python script will accept, you can check the config.ini file contained within the config folder here

Syntax for args

Currency pairs passed in must adhere to Oandas v20 schema - capital letters separated by an underscore. i.e. You must use EUR_USD rather than eur_usd or eurusd or EURUSD or some other variation. If you would like more information on this, you can view the Oanda Instrument developer docs here.

None of the automated trading strategies are profitable! They are for demonstration and testing purposes only

Disclaimer:

Trading foreign exchange carries a high level of risk, and may not be suitable for all investors. Past performance is not indicative of future results. Leverage can work against you as well as for you. Before deciding to invest in foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts.

I take no responsibility for any losses or gains you may incur from using my software. I also take no responsibility for any architecture, security, or server configurations.

This software is provided as is. No warranties or guarantees will be provided for its accuracy, completeness, reliability, or security if used within your own environment.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oanda_v20_platform-ant358-0.1.1.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oanda_v20_platform_ant358-0.1.1-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file oanda_v20_platform-ant358-0.1.1.tar.gz.

File metadata

  • Download URL: oanda_v20_platform-ant358-0.1.1.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.4

File hashes

Hashes for oanda_v20_platform-ant358-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5d79c3a96007ed8aa2080a9e0bf099cbdeb074db2f3a6911e8d454e44f9f8557
MD5 8741d570628b972fdecbe0c8b4e6a9a7
BLAKE2b-256 b7758dcd380706d1218cae92b046bc9d4a71ae75542a43d181c7b749f92c5c3e

See more details on using hashes here.

File details

Details for the file oanda_v20_platform_ant358-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: oanda_v20_platform_ant358-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.4

File hashes

Hashes for oanda_v20_platform_ant358-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d124b8b3e2d12ccefaf1088defa13d8bedd658fcae9d861135d86d396ee60724
MD5 2474ac2a56924cd02de1a3150f1402be
BLAKE2b-256 926ea88b99ae33acc1549560958be7e3290f00c98fac24664fb579b85a96f7b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page