Learning to trade under the reinforcement learning framework

Overview

Trading Using Q-Learning

In this project, I will present an adaptive learning model to trade a single stock under the reinforcement learning framework. This area of machine learning consists in training an agent by reward and punishment without needing to specify the expected action. The agent learns from its experience and develops a strategy that maximizes its profits. This is my capstone project for the Machine Learning Engineer Nanodegree, from Udacity. You can check my report here and the notebook with the tests of the codes used in this project here. The TEX file was produced with help of Overleaf.

Install

This project requires Python 2.7 and the following Python libraries installed:

Run

In a terminal or command window, navigate to the top-level project directory QLearning_Trading/ (that contains this README) and run one of the following commands:

python qtrader/agent.py <OPTION>
python -m qtrader.agent <OPTION>

Where OPTION could be train_learner, test_learner, test_random, optimize_k or optimize_gamma. The simulation will generate log files to be analyzed later on. Be aware that any of those commands take several minutes to finish.

Reference

  1. T.M. Mitchell. Machine Learning. McGraw-Hill International Editions, 1997. link
  2. M. Mohri, A. Rostamizadeh, A. Talwalkar. Foundations of Machine Learning. 2012. link
  3. N.T. Chan, C.R. Shelton. An Electronic Market-Maker. 2001 link
  4. N.T. Chan. Artificial Markets and Intelligent Agents. 2001 link
  5. R. Cont, k. Arseniy, and S. Sasha. The price impact of order book events. Journal of financial econometrics, 2014 link
  6. Du, Xin, Jinjian Zhai, and Koupin Lv. Algorithm Trading using Q-Learning and Recurrent Reinforcement Learning. link

License

The contents of this repository are covered under the Apache 2.0 License.

You might also like...
Official implementation of "Not only Look, but also Listen: Learning Multimodal Violence Detection under Weak Supervision" ECCV2020

XDVioDet Official implementation of "Not only Look, but also Listen: Learning Multimodal Violence Detection under Weak Supervision" ECCV2020. The proj

Boost learning for GNNs from the graph structure under challenging heterophily settings. (NeurIPS'20)

Beyond Homophily in Graph Neural Networks: Current Limitations and Effective Designs Jiong Zhu, Yujun Yan, Lingxiao Zhao, Mark Heimann, Leman Akoglu,

MazeRL is an application oriented Deep Reinforcement Learning (RL) framework
MazeRL is an application oriented Deep Reinforcement Learning (RL) framework

MazeRL is an application oriented Deep Reinforcement Learning (RL) framework, addressing real-world decision problems. Our vision is to cover the complete development life cycle of RL applications ranging from simulation engineering up to agent development, training and deployment.

PGPortfolio: Policy Gradient Portfolio, the source code of "A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem"(https://arxiv.org/pdf/1706.10059.pdf).

This is the original implementation of our paper, A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem (arXiv:1706.1

A parallel framework for population-based multi-agent reinforcement learning.
A parallel framework for population-based multi-agent reinforcement learning.

MALib: A parallel framework for population-based multi-agent reinforcement learning MALib is a parallel framework of population-based learning nested

gym-anm is a framework for designing reinforcement learning (RL) environments that model Active Network Management (ANM) tasks in electricity distribution networks.
gym-anm is a framework for designing reinforcement learning (RL) environments that model Active Network Management (ANM) tasks in electricity distribution networks.

gym-anm is a framework for designing reinforcement learning (RL) environments that model Active Network Management (ANM) tasks in electricity distribution networks. It is built on top of the OpenAI Gym toolkit.

Yet Another Robotics and Reinforcement (YARR) learning framework for PyTorch.
Yet Another Robotics and Reinforcement (YARR) learning framework for PyTorch.

Yet Another Robotics and Reinforcement (YARR) learning framework for PyTorch.

YARR is Yet Another Robotics and Reinforcement learning framework for PyTorch.
YARR is Yet Another Robotics and Reinforcement learning framework for PyTorch.

Yet Another Robotics and Reinforcement (YARR) learning framework for PyTorch.

An efficient framework for reinforcement learning.

rl: An efficient framework for reinforcement learning Requirements Introduction PPO Test Requirements name version Python =3.7 numpy =1.19 torch =1

Comments
  • Bug: Learning_trade.ipynb Please Help

    Bug: Learning_trade.ipynb Please Help

    I have not changed any of the files and Running the example fails for me when I run:

    import qtrader.eda as eda; reload(eda); df_last_pnl = eda.plot_cents_changed(archive, archive2)

    program crashes in plot_cents_changed(archive, archive2) with error message:

    424     # filer data
    

    --> 425 na_hour = np.array([x.hour*60 + x.minute for x in quotes.index]) 426 quotes = quotes[(na_hour >= (10 * 60 + 30)) & (na_hour <= (16 * 60 + 30))] 427 na_days = np.array([x.day for x in quotes.index])

    AttributeError: 'tuple' object has no attribute 'hour'

    opened by rsadr 8
Owner
Uirá Caiado
Uirá Caiado
Reinforcement-learning - Repository of the class assignment questions for the course on reinforcement learning

DSE 314/614: Reinforcement Learning This repository containing reinforcement lea

Manav Mishra 4 Apr 15, 2022
Mind the Trade-off: Debiasing NLU Models without Degrading the In-distribution Performance

Models for natural language understanding (NLU) tasks often rely on the idiosyncratic biases of the dataset, which make them brittle against test cases outside the training distribution.

Ubiquitous Knowledge Processing Lab 22 Jan 2, 2023
DiffQ performs differentiable quantization using pseudo quantization noise. It can automatically tune the number of bits used per weight or group of weights, in order to achieve a given trade-off between model size and accuracy.

Differentiable Model Compression via Pseudo Quantization Noise DiffQ performs differentiable quantization using pseudo quantization noise. It can auto

Facebook Research 145 Dec 30, 2022
Code of the paper "Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speech Recognition"

SEW (Squeezed and Efficient Wav2vec) The repo contains the code of the paper "Performance-Efficiency Trade-offs in Unsupervised Pre-training for Speec

ASAPP Research 67 Dec 1, 2022
SpeechNAS Better Trade off between Latency and Accuracy for Large Scale Speaker Verification

SpeechNAS Better Trade off between Latency and Accuracy for Large Scale Speaker Verification

Wentao Zhu 24 May 20, 2022
Uses Open AI Gym environment to create autonomous cryptocurrency bot to trade cryptocurrencies.

Crypto_Bot Uses Open AI Gym environment to create autonomous cryptocurrency bot to trade cryptocurrencies. Steps to get started using the bot: Sign up

null 21 Oct 3, 2022
A general framework for deep learning experiments under PyTorch based on pytorch-lightning

torchx Torchx is a general framework for deep learning experiments under PyTorch based on pytorch-lightning. TODO list gan-like training wrapper text

Yingtian Liu 6 Mar 17, 2022
A generalized framework for prototyping full-stack cooperative driving automation applications under CARLA+SUMO.

OpenCDA OpenCDA is a SIMULATION tool integrated with a prototype cooperative driving automation (CDA; see SAE J3216) pipeline as well as regular autom

UCLA Mobility Lab 726 Dec 29, 2022