Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepSeek-HFT

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".

Prerequisites

Install the Python dependencies from requirements.txt:

pip install -r requirements.txt

Usage

Download Sample Datasets

To 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.

Run Data Pre-Processing

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.py

This 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.

Run Alpha Extraction

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.csv

This trains the alpha extraction model and saves the resulting checkpoint as models/alpha_extraction/AAPL.pt.

Run Backtesting

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.

Generate Plots

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/plots

Useful optional flags:

python3 advanced_plots.py --data_dir ../data --instrument AAPL --agents ppo grpo gspo --out ../plots --heatmaps --alpha_curves --train_curves --alpha_metrics

This will save plots and metrics under outputs/plots (or the output directory you provide).

Citation

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}, 
}

License

Read the LICENSE file.

Releases

Packages

Contributors

Languages