Coder Social home page Coder Social logo

cove9988 / tradinggym Goto Github PK

View Code? Open in Web Editor NEW
208.0 17.0 58.0 22.57 MB

Trading Gym is an open source project for the development of reinforcement learning algorithms in the context of trading.

License: MIT License

Python 2.18% Shell 0.09% Jupyter Notebook 97.73%
python3 trading forex currency machine-learning dqn stock-trading

tradinggym's Introduction

TradingGym

Trading Gym (>Python 3.7)

Trading Gym is an open-source project for the development of deep reinforcement learning algorithms in the context of forex trading.

Highlight of the project

  1. customized gym.env for forex trading, with three actions (buy,sell, nothing). rewards is forex point based and realized by stop loss (SL) and profit taken (PT). The SL is fixed by passing parameter and PT is AI learning to maximize the rewards.
  2. multiply pairs with same time frame, time frame can setup from 1M, 5M, 30M, 1H, 4H. Both over night cash penalty, transaction fee, transaction overnight penalty (SWAP) can be configured.
  3. data process will split the data into daily, weekly or monthly time serial based. and will training in parallel by using Isaac or Ray (coming soon)
  4. file log, console print-out and live graph are available for render

Major Feature

  1. forex feature

    1.1. using Point (5 decimal forex ) for reward and balance calculation

    Basis point

    The last decimal place to which a particular exchange rate is usually quoted is referred to as a point.

Trading Plot

GBTUSD 1
GBTUSD 2 GBTUSD 3 2. data process: (./data/data_process.py)

2.1. processing csv (time, open, high, low, close), the source I used is MetaTrader.

2.2. adding a few required features, such as symbol, day, etc...

2.3. adding TA features by using finta

2.4. splitting data based on time serial into weekly or monthly

2.5 combining different trading pair (e.g GBPUSD, EURUSD...) into on csv for vector process. (so far manually)
  1. environment:

    3.1. action_space = spaces.Box(low=0, high=3, shape=(len(assets), ))

    3.2. _action = floor(action) {0:buy, 1:sell,2:nothing}

    3.3. action_price is the current candlestick close price.

    3.4. observation_space contains current balance, .. (draw down) * assets + (TA features)*assets

    3.5. using fix stop_loss (SL) parameter and fraction calculation for profit_taken (PT) as a part of action

    3.6. overnight cash penalty, transaction fee, transaction holding over night penalty

    3.7. rewards will be realized once SL or PT trigger at next step

    3.8. max holding

    3.9. done when balance <= x or step == len(df) [reach the weekend] if step == len(df) close all holding position at close price.

The trading environment:

Candle Trading is a trading environment with input ohlc (open, high,low,close candlestick/bar) data, it is very useful to forex (currency) trading. We use profit-taking (machine learning) and fixed stop-loss.

Create your own data_process

To create your own data, you can use data_process base class which can be found in the file 'data/data_process.py'.

Compatibility with OpenAI gym

The tgym (trading environment) is inherited from OpenAI Gym. We aim to entirely base it upon OpenAI Gym architecture and propose Trading Gym as an additional OpenAI environment.

Examples

ppo_test.ipynb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.