Giter Club home page Giter Club logo

fire's Introduction

🔥 FiRe: Financial Reinforcement Learning by Trality

Welcome to FiRe! FiRe is a Reinforcement Learning (RL) pipeline built to research Single- and Multi-Objective trading algorithms.

What is supported?

  • Critic-only Deep Q-Learning RL agent with Hindsight Experience Replay link
  • Single- and Multi-Objective reward learning with generalization in the sense of [Friedman, Fontaine]
  • MLP-type agent’s Neural Network
  • Four reward mechanisms (last logarithmic return, average logarithmic return, Sharpe Ratio, profit only when closing)

Install

We recommend python version 3.10. (Check your version with python3 --version)

We recommend using a virtual environment: to create it, run

python3 -m venv .venv
source .venv/bin/activate

in the repository's main folder.

Install the required packages and download the Bitcoin dataset by running

make

in the main folder.

Test

To test the code you can run the sin-wave example:

python3 main.py parameters/sin_wave_test_multi.json

How to run an experiment

In order to run a particular experiments run the main.py script adding as argument a json configuration file:

python3 main.py <your configuration file>.json

the json configuration file contains information about:

  • The chosen dataset
  • The reward or set of rewards to use
  • Q-Learning general parameters
  • Neural Network hyperparameters

Experiments results are stored in the results_of_experiments folder, each subfolder contains the results of each single experiment.

Reproduce experiments in paper (Bitcoin dataset only)

We provide all configuration files for the experiments on the Bitcoin dataset that are shown in the paper. To run the experiments use:

git checkout e2bc651b07eec388ee0b03228e0acdee8550ba7d
sh scripts/run_experiments_in_folder.sh parameters/paper_plots

Datasets

For the simulation we discussed in our paper we used the following datasets:

  • Cryptocurrency price data (BTCUSDT, ETHUSDT, XRPUSDT) from Binance exchange, downloaded through Binance API
  • Stocks price data (AAPL, SPY), downloaded from Yahoo!finance through yfinance python package
  • Nifty50 minute close price, downloaded from Kaggle

You can download all cryptocurrencies and stocks datasets by running:

make datasets

that will run the download_datasets.sh script (this is not necessary if you already ran make)

Nifty50 dataset can instead be downloaded from kaggle at this link

Latex for plots

If you want to use latex to create the plots you need to install the following packages:

sudo apt-get install texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra dvipng

You can now set "text.usetex": True, at the top of src/plots.py.

Acknowledgement of sources

Our code utilizes parts of the following open source repositories:

  1. The Deep Q-Network implementation at https://github.com/mswang12/minDQN
  2. The stocks environment at https://github.com/AminHP/gym-anytrading

fire's People

Contributors

disselkamp avatar davidescassola avatar

Stargazers

 avatar Nelson avatar  avatar Hyeokryeol Yang avatar  avatar Emanuele Ballarin avatar Gokul avatar  avatar Derek Centineo avatar  avatar  avatar  avatar  avatar  avatar  avatar Franky1 avatar Thibault Ramires avatar Ioan Festeu avatar  avatar  avatar Pavel Medvedev avatar Andrea Salcedo avatar Laurin Lukas Stahl avatar Sabrina Medwinter avatar  avatar T avatar christopher avatar

Watchers

Mark R Best avatar  avatar

fire's Issues

missing function

environment/environment.py,there is no function _calculate_reward which is used in line 82.

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.