CoolFace
Apppublic

devsachan23/crude_oil_quant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
App README

๐Ÿ›ข๏ธ Crude Oil Systematic Walk-Forward Strategy

Brent Crude Total Return Index (2016โ€“2024) Sharpe: 0.847 vs Baseline: 0.462


๐Ÿ“Œ Project Overview

This project implements a systematic multi-signal trading framework on the Brent Crude Total Return Index using:

  • โ€”Diversified signal construction (Trend, Mean Reversion, Volatility-aware, Orthogonal)
  • โ€”Walk-forward adaptive strategy selection
  • โ€”Volatility targeting (15% annualized)
  • โ€”Transaction cost modeling (0.015% per trade)
  • โ€”Regime attribution analysis

The primary objective is to maximize out-of-sample Sharpe ratio in a realistic setting, strictly avoiding look-ahead bias.

All strategy selection decisions are made using only information available at each rebalance date.


โš™๏ธ Strategy Architecture

๐Ÿ”น Signal Groups (11 Base Signals)

Trend-Following

  • โ€”1M Momentum
  • โ€”3M Momentum
  • โ€”200D Moving Average Crossover

Mean Reversion

  • โ€”20D Z-score Reversion
  • โ€”5D Reversal
  • โ€”Percentile Reversion

Volatility-Aware

  • โ€”Vol-Adjusted Momentum
  • โ€”Volatility Breakout
  • โ€”Volatility Trend

Orthogonal

  • โ€”Carry Proxy (Momentum Spread)
  • โ€”Momentum ร— Volatility Filter

Each base signal is extended with a volatility-scaled variant.

Final candidate pool:

  • โ€”11 base
  • โ€”11 vol-scaled
  • โ€”1 equal-weight ensemble = 23 competing strategies

๐Ÿ”„ Walk-Forward Framework

Every 6 months:

  1. 1.Evaluate all 23 candidate strategies over the previous 18 months
  2. 2.Score using composite metric:0.6 ร— Sharpe + 0.4 ร— Sortino
  3. 3.Select best performer
  4. 4.Deploy out-of-sample until next rebalance

This process ensures:

  • โ€”No look-ahead bias
  • โ€”Adaptive strategy selection
  • โ€”Reduced overfitting risk

Walk-forward logic mirrors the provided WalkforwardBacktester implementation.


๐ŸŽฏ Risk Management

  • โ€”Transaction Cost: 0.015% per trade
  • โ€”Volatility Target: 15% annualized
  • โ€”Volatility Estimate: 63-day EWM (1-day lag)
  • โ€”Leverage Scalar Clipped to: [0.25ร—, 4ร—]

Volatility targeting is applied before strategy selection so all candidates compete on equal risk footing.


๐Ÿ“Š Performance Summary

MetricBaselineWalkforward
Sharpe0.4620.847
Sortino0.5811.096
CAGR10.9%13.1%
Volatility39.5%16.1%
Max Drawdown78.2%22.1%
Calmar0.1390.592

Improvement is driven primarily by disciplined volatility control and adaptive selection rather than aggressive directional forecasting.

The strategy demonstrates resilience during high-volatility regimes, particularly during the 2020 oil crash.


๐ŸŒก๏ธ Regime Attribution

Performance is decomposed across:

  • โ€”High Volatility (>65th percentile)
  • โ€”Low Volatility (<35th percentile)
  • โ€”Neutral Regime

Results indicate consistent performance across regimes, with enhanced stability during extreme volatility periods.


๐Ÿ’ป Interactive Dashboard

An interactive Streamlit dashboard allows:

  • โ€”Strategy selection
  • โ€”Walk-forward parameter tuning
  • โ€”Volatility targeting adjustments
  • โ€”Regime filtering
  • โ€”Rolling Sharpe visualization
  • โ€”Selection frequency diagnostics
  • โ€”Full performance comparison

Run locally:

bash
streamlit run app.py
๐Ÿ“‚ Repository Structure
app.py                         # Streamlit dashboard
backtest.py                    # Walkforward backtester class
crude_oil_strategy.ipynb       # Research notebook
crude_oil_strategy.html        # HTML export of notebook
brent_index.xlsx               # Data file
performance_summary_improved.csv
requirements.txt
README.md
๐Ÿ“ฆ Installation
pip install -r requirements.txt
๐Ÿง  Design Philosophy
This project emphasizes:

Out-of-sample integrity

Adaptive systematic allocation

Risk-adjusted performance over raw returns

Clean, reproducible implementation

The objective is disciplined quantitative design rather than curve-fitting.

๐Ÿš€ Future Extensions
Multi-commodity extension

True futures carry implementation

Cross-asset regime conditioning

Longer historical backtesting

๐Ÿ‘ค Author
Dev Sachan
Quantitative Strategy Project
2026