ML HFT
High frequency trading (HFT) framework built for futures using machine learning and deep learning techniques
Install / Use
npx skills add bradleyboyuyang/ML-HFTInstalls into whichever agent you are using.
README
High Frequency Trading Framework with Machine/Deep Learning
In this project, we provide a framework/pipeline for high frequency trading using machine/deep learning techniques. More advanced feature engineering (with depth trade and quote data) and models (such as pre-trained models) can be applied in this framework.
Target
- Extract trading signals from level-II orderbook data
- Predict orderbook dynamics using machine learning and deep learning techniques
Data
The SGX FTSE CHINA A50 INDEX Futures (新加坡交易所FTSE中国A50指数期货) tick depth data are used.
Strategy Pipline
<img src="./Graph/pipline.png" width="650">Orderbook Signals
We use limit orderbook data to develop trading signals, including Depth Ratio, Rise Ratio, and Orderbook Imbalance (OBI).
<img src="./Graph/depth.png" width="650">Price Series
<img src="./images/best_bid_ask.png" width="750">Feature Engineering & HFT Factors Design
- Simple average depth ratio and OBI:
- Weighted average depth ratio, OBI, and rise ratio:
Model Fitting
-
Basic Models:
- RandomForestClassifier
- ExtraTreesClassifier
- AdaBoostClassifier
- GradientBoostingClassifier
- Support Vector Machines
- Other classifiers: Softmax, KNN, MLP, LSTM, etc.
-
Hyperparameters:
- Training window: 30min
- Test window: 10sec
- Prediction label: 15min forward
Performance Metrics
- Prediction accuracy:
-
Prediction Accuracy Series:
<img src="./images/single_day_accuracy.png" width="800"> -
Cross Validation Mean Accuracy:
- Best Model:
PnL Visualization
<img src="./images/best_CV_result_all.png" width="800">Improvements
Feature Engineering
Other potentially useful signals:
- volume imbalance signal
- trade imbalance signal
- technical indicators of bid and ask series (RSI, MACD...)
- WAP/WPR, weighted average price, VWAP, TWAP
- .....
Signal generating techniques:
- consider different weights on different level of orderbook data for a particular signal
- consider moving average with period n (hyperparameter)
- consider weighted average of signals, such as weighted average of trade imbalance and orderbook imbalance
- Lasso regression, genetic programming
- .....
Models
This project only provides a baseline. More advanced models are welcomed:
- CNN
- GRU/LSTM
- XGBoost, AdaBoost, GBDT, LightGBM
- Attention, Auto-encoder
- TabNet
- Pre-trained models
- .....
Performance Metrics
The performance metrics are subject to amendment, including the PnL calculation, commission fee consideration, etc.
Related Skills
mcp
Use the `mcp_perplexity-ask_perplexity_search` tools to answer questions. You should use this instead of the `web_search` tool because it is a lot more accurate.
practical-power-systems-synthesis
This skill enables synthesis in the domain of power-systems (engineering). It represents research-level-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform synthesis operations related to power-systems.
semi-supervised-optogenetics-testing
This skill enables testing in the domain of optogenetics (neuroscience). It represents intermediate-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform testing operations related to optogenetics.
data-mining-interpretation-fundamental
This skill enables interpretation in the domain of data-mining (data-science). It represents fundamental-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform interpretation operations related to data-mining.
