This repository presents a comprehensive analysis of mean-reverting statistical arbitrage strategies applied to a futures pair:
Heating Oil (HO) and Low-Sulfur Gasoil (LGO), using high-frequency intraday data.
The study includes:
- Data loading, filtering, and preprocessing
- Ornstein-Uhlenbeck (OU) process calibration using bootstrap methods
- Optimal trading band selection under transaction costs and stop-loss constraints
- In-sample (IS) and out-of-sample (OS) performance assessment
Two parallel implementations are provided:
Energy-Trading-Python/: Complete Python pipelineEnergy-Trading-MATLAB/: MATLAB modules and scripts
README.md: This fileHO-LGO.xlsm: Raw futures data in Excel with macrosrequirements.txt: Python dependenciesFinal_Project_Group_8B_Report.pdf: Final report (PDF-style).gitignore: Git tracking exclusionsvenv/: Python virtual environment (not tracked)
Python implementation of the project with utilities and crypto extensions:
| File/Folder | Description |
|---|---|
Final_Project_Group_*.ipynb |
📓 Jupyter notebooks with full pipeline |
Final_Project_Crypto_*.ipynb |
Crypto adaptation of the strategy |
crypto_dataset/ |
Additional datasets for crypto testing |
utilities/ |
Modular utility functions (data, plots, stats, etc.) |
path/ |
File and directory path utilities |
PDF/ |
Generated PDF outputs |
Modular MATLAB codebase structured into functional blocks:
| Folder | Description |
|---|---|
Cost & Analysis Utilities/ |
Transaction cost handling and performance metrics |
Data/ |
Data files (converted/cleaned) |
Data Processing/ |
Trimming and filtering scripts |
OU model Estimation .../ |
OU model calibration and bootstrap |
Trading Strategy & Bands/ |
Trading rules and band computation |
Prints and Plots/ |
Visual results |
Final_Project_Group_*.mlx |
Main live script notebook (MATLAB) |
- Install dependencies (preferably in a virtual environment):
pip install -r requirements.txt- Run the main Jupyter Notebooks:
jupyter notebook Energy-Trading-Python/Final_Project_Group_*.ipynbThis project was developed as part of a university coursework on quantitative trading and statistical arbitrage.
The methodology is based on the paper by Baviera (2019), available in the PDF/ folder.
This project received the highest grade in the course, validating both the correctness of the implementation and the depth of the analysis.
All results and methods were thoroughly reviewed by the academic supervisors.
This project is licensed under the MIT License — see the LICENSE file for details.
Please note that the original repository, which contains the complete commit history and development process, is private.
This is due to the presence of academic material and internal coursework content that cannot be publicly shared.
This public version has been curated for portfolio and educational purposes, and faithfully reflects the structure, results, and methodology of the original work.