Code Monkey home page Code Monkey logo

ml-stock-prediction's Introduction

ml-stock-prediction

This repository aims to use Reinforcement Learning to backtest and live trade cryptocurrencies with custom OpenAI Gym environments.

Prerequisites

To get this project up and running on your machine, and mainly to be able to use the trading environments, a few dependencies must first be installed. Firstly to install if not already installed NumPy, Pandas, Jupyter and matplotlib by doing:

pip install numpy matplotlib ipython jupyter pandas

OpenAI Gym must also be installed, which can be done with:

pip install gym

Please refer to the OpenAI Gym repo for more information.

To get historical data, place orders or making other requests from GDAX, the unoficial GDAX python client by Daniel Paquin is used, which can be installed once again using pip:

pip install gdax

OpenAI Environments

The testing environment

Similarly to other OpenAI environments, this one can be instanced by

import gym
import trading_env

env_trading = gym.make('test_trading-v0')

It uses GDAX historical data from January 2017 to March 2018, and a start date can be specified when reseting the environment. A random start date is otherwise chosen.

env_trading.reset(date=datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0))

One episode represents one month starting at date with timesteps of 15 minutes. Every step returns the last 200 closing prices and volume up until the current step, relative to (divided by) the current closing price and volume. The actions range from -1 to 1 and represent the percentage of the portfolio's crypto sold or fiat used to buy, respectively.

States Actions Rewards
Box(100, 2) Box(1) (-inf, inf)

The reward is computed as the relative difference of portfolio value since the last timestep:

reward = (current portfolio value - previous portfolio value)/previous portfolio value

The Live Environment

This one is still under development

ml-stock-prediction's People

Contributors

guilhermegsousa avatar

Watchers

James Cloos avatar  avatar

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.