This repository contains the code to reproduce the experiments of the paper "DeepSeekMath Meets Order Book: Group-Aware Policy Optimization for High-Frequency Directional Trading".
Install the Python dependencies from requirements.txt:
pip install -r requirements.txtTo run the preprocessing and backtesting workflow, download sample LOBSTER order-book data from this link.
Place the downloaded sample files in a folder that matches the input paths expected by src/data_process.py, or update the file paths in that script to point to your local dataset directory.
The preprocessing script in src/data_process.py builds a processed CSV from LOBSTER message/order-book files.
From the repository root, run:
cd src
python3 data_process.pyThis writes a processed file named AAPL.csv in the current working directory for instrument AAPL. If your sample files are stored under a different directory, update the file paths inside src/data_process.py to point to those files.
Before running backtesting, train the alpha extraction model if the corresponding artifact is not already present under models/alpha_extraction.
From the repository root, run:
cd src
python3 -m trainers.alphaExtraction ../data/AAPL.csvThis trains the alpha extraction model and saves the resulting checkpoint as models/alpha_extraction/AAPL.pt.
Backtesting is implemented in src/backtesting.py. It expects trained model artifacts under models and a processed data file such as data/AAPL.csv.
Run it from the source directory:
cd src
python3 backtesting.py ../data/The script will load the configured instrument and print the performance metrics for the selected agent setup.
The plotting workflow lives in src/advanced_plots.py. It can generate equity curves, reward plots, and optional heatmaps/alpha-metric visualizations.
Example:
cd src
python3 advanced_plots.py --data_dir ../data --instrument AAPL --agents all --out ../outputs/plotsUseful optional flags:
python3 advanced_plots.py --data_dir ../data --instrument AAPL --agents ppo grpo gspo --out ../plots --heatmaps --alpha_curves --train_curves --alpha_metricsThis will save plots and metrics under outputs/plots (or the output directory you provide).
If you use this codebase in academic work, please cite:
@misc{charabarty2026deepseekmathmeetsorderbook,
title={DeepSeekMath Meets Order Book: Group-Aware Policy Optimization for High-Frequency Directional Trading},
author={Sayak Charabarty and Souradip Pal},
year={2026},
eprint={2605.25527},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2605.25527},
}
Read the LICENSE file.