Code Monkey home page Code Monkey logo

q_learning_trading's Introduction

Q-Learning Trading Agent

Introduction

Design a learning trading agent that uses a Q-learning-based strategy and technical indicators. This is Part 4 in a four-part series of Machine Learning Algorithms:

  • Part 1: Implement the Linear Regression Learner and Decision Tree Learner and generate data that works better for one learner than the other.
  • Part 2: Implement Random Tree Learner, Bag learner and Insane Learner. Evaluate all the learners implemented in Parts 1 and 2.
  • Part 3: Implement the Q-Learning and Dyna-Q solutions to the reinforcement learning problem.
  • Part 4 (this repository): Implement a learning trading agent using Q-learning.

Code

  • StrategyLearner.py - Main code for a StrategyLearner that uses Q-learning and technical indicators to trade a stock.
  • q_learning_trading_example.ipynb - Example of how a StrategyLearner works. This code is also available in the __main__ function of StrategyLearner.py.
  • QLearner.py - Code for Q-learning, a reinforcement learning technique. It was first developed and tested in a navigation problem in Part 3.
  • indicators.py - Technical indicators to be used as features by a StrategyLearner. They were first developed and used in a rule-based trading strategy
  • marketsim.py - A market simulator that computes and visualizes statistics from trades generated by a StrategyLearner. It was first developed in Computational Investing, but has been updated here to read in a dataframe of trades instead of a csv file. There is also an update on how it visualizes a stock's performance.
  • analysis.py - Helper code for marketsim.py. It was first developed in Analyze Financial Data
  • util.py - Util functions for StrategyLearner.py, e.g. loading data, creating dataframes, etc.
  • grade_strategy_learner.py - Main test code for StrategyLearner
  • grading.py - Helper test code for grade_strategy_learner.py

Setup

You need Python 2.7.x or 3.x (recommended), and the following packages: pandas, numpy, and matplotlib.

Data

Data files can be downloaded from this link or from Yahoo Finance

Place the data into a directory named 'data' and it should be one level above this repository.

Run

To run any script file, use:

python <script.py>

To run any IPython Notebook, use:

jupyter notebook <notebook_name.ipynb>

Source: Part 3 of Machine Learning for Trading by Georgia Tech

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.