Giter Site home page Giter Site logo

arnoldkuo / reinforcement-learning-stock-trader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kroat/reinforcement-learning-stock-trader

1.0 1.0 0.0 415 KB

Reinforcement Learning Script that trades Equities from Yahoo Finance

License: GNU General Public License v3.0

Python 100.00%

reinforcement-learning-stock-trader's Introduction

Reinforcement Learning Stock Trader

What:

This Reinforcement Learning Stock Trader uses a mix of human trading logic and Q-Learning to trade Equities found on Yahoo.com/finance in your terminal!

It works by running defined trading logic for a set of historical trades, and then hands over the torch to Q-Learning for the remaining set of historical data.

Simple Quick Guide

To use:

  1. Make sure all necessary libraries are installed: Numpy, Pandas, Scipy
  2. Clone this project into any directory on your machine
  3. CD into the project directory
  4. Pass the following commmand: python RL-Trader.py [EQUITY] [START DATE - DAY/MONTH/YEAR] [STARTING PORTFOLIO VALUE] [DAYS TO LEARN]

For example: python RL-Trader.py F 1/1/2000 1000 100

^ This command runs the RL script against Ford's historical data and learns using our trading logic (under logic/logic.py) for 100 days before Reinforcement Learning kicks in with a starting portfolio of $1,000. The resulting Q-Table, as well as the profit, is then printed.

What this code does well (so far)

I have found that this script works especially well against times of economic contraction. That being said, results are contingent on the trading logic given to the RL agent, as well as the attributes of the RL agent itself.

Reinforcement Learning Logic

Unlike other Reinforcement Learning scripts, it is better to keep the greedy factor (Epsilon) low (around .05-.5) as it increases the amount of analytical decisions the script makes. Because markets have a stochastic factor, it did not make sense to have the script choose a random 'buy' or 'sell' call, but instead use logic an analyist might use (this is under state_logic), only maximizing when there is enough data in the Q-Table (analagous to traders using trading strategies that have worked before).

Add your own trading logic!

Navigate to Logic/logic.py and edit the

def state_logic()

function (ignore the function inputs). Add your trading logic here -- when the function returns 0, the agent learns to sell. When the fucntion returns 1, the agent learns to buy.

Planned Features to Add:

  1. Calculation for Alpha compared to given Equity/Market
  2. Ability to add more than one equity

If you'd like to see anything added -- feel free to message me: [email protected]

reinforcement-learning-stock-trader's People

Contributors

kroat avatar

Stargazers

 avatar

Watchers

 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.