Git Product home page Git Product logo

gym-stocks's Introduction

gym-stocks

OpenAI gym to play with stock market data

  1. Download stock data in comma-separated CSV format, following fields are required 'Date', 'Time', 'Open', 'High', 'Low', 'Close', 'Volume' into stocks/ directory within this git sources, each separate equity datafile should have .csv extension
  2. Install gym-stocks
pip install --user -e .
  1. Run example
import gym
import gym_stocks
env = gym.make('Stocks-v0')
print env.reset()
  1. Initial (reset) conditions You have 1000000 units of money and zero equity. Opeartion comission is 0.1%, there is no inflation (will be added if needed), i.e. negative reward per HOLD action.

gym-stocks opens one random csv file from stocks directory at every reset() call and yields one line per step. No normaization is being performed.

Every buy/sell action uses previous close price, i.e. not the price returned by the step() call, comission is being applied per each of these actions. Only 1 stock is being processed in these steps, i.e. if you select BUY, and the price is 50, only one stock will be bought (you will pay 50*(1+0.1/100)) even if you have more money.

If you do not have enough money to perform BUY action or you do not have equity to perform SELL action, nothing happens.

Portfolio cost equals to the sum of the money and equity times the closing price. Reward is a difference between portfolio cost at the current and previous steps, reward calculation is being performed after money and equity have been updated (with the appropriate comission).

gym-stocks's People

Contributors

bioothod 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.