Giter Club home page Giter Club logo

rl_optimal_execution's Introduction

RL 2023 Optimal Execution

This repository contains a code implementation of the Research project Optimal Trade Execution using RL approach.

Idea:

This project aims to tackle the challenging problem of optimizing the execution of large orders in financial markets, whether they are simulated environments or real-world platforms like Binance. Efficiently executing large orders while minimizing costs and market impact is crucial for institutional investors and traders. Reinforcement Learning provides a promising approach to address this problem by learning optimal execution strategies in complex market dynamics.

Simulator:

$$dQ_v^t = -v_tdt$$

$$dS_v^t = -bv_tdt+\sigma dW_t$$

$$c_v^t =(((S_v^t - k\sqrt {v_t}) - t|v_t|)v_t -\rho(Q_t^v)^2)dt$$

where $Q_v$ is asset volume, $S_v$ is return by GMB process, $v_t$ - action, $c_v^t$ - cash, $k$ - temporary price impact coef, $b$ -permanent price impact coef, $\rho$ - inventory risk coef

In real market we assume $b$ = 0 and instead of $k\sqrt {v_t}$ compute real price decrease by the order book. What is more, high 5 bid and asks are taken as observations and reasonably real market price $S_v^t$ is taken from market, as midprice from best ask and bid.

Running cost

$$r_{t+1} = -dc_v^{t+1} + (Q_v^t<0)$$

Repo description

Prerequisites

git clone https://github.com/ooodnakov/RL-2023-TP-Optimal-Execution
cd RL-2023-TP-Optimal-Execution
pip install -r requirements.txt
wget https://dnakov.ooo/files/data.parquet

Running

To reproduce results, you just ran our notebooks using Python kernel with neccesary packages.

The code was tested in Python 3.9.16. The code execution in other Python versions is not guaranteed.

If you prefere .py files you can run them via:

python actor_critic.py actor_critic_params.yaml
python actor_critic_historical.py actor_critic_historical_params.yaml data.parquet

Results

We succeded to beat TWAP results in execution in both simulated and real markets.

Simulated market

alt text

alt text

alt text

RL allowed to receive more than 33% more cash compared to TWAP baseline

Real market

alt text

alt text

alt text

rl_optimal_execution's People

Contributors

matteus1904 avatar dependabot[bot] 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.