A systematic trading framework for WTI Crude Oil futures, based on the research by Quant Insider. This project implements a multi-factor strategy that combines Momentum, Term Structure (Carry), and Volatility Risk Premium, managed by a nonlinear reaction function for position sizing.
This algorithm automates the analysis of three core quantitative edges in commodity markets:
- Momentum: Captures inventory-driven price trends using volatility-normalized filters.
-
Carry (Curve Structure): Exploits the "roll yield" by tracking the spread between near-term (USO) and long-term (USL) exposure.
-
Backwardation (Tight Supply)
$\rightarrow$ Long Signal -
Contango (Oversupply)
$\rightarrow$ Short/Neutral Signal
-
Backwardation (Tight Supply)
-
Volatility Risk Premium (VRP): Uses the spread between Implied Volatility (
OVX) and Realized Volatility to bias direction.
Unlike linear models, this strategy uses a Nonlinear Reaction Function to size positions.
- Logic: As signal strength increases, position size increases. However, if the signal becomes too strong (>2 Sigma), the model reduces exposure to avoid "crowded trades" and mean reversion risk.
pip install -r requirements.txt
### 2. Run the Strategy
```bash
python live_oil_strategy.py
## Sample Output
========================================
QUANT OIL STRATEGY: 2025-11-24
========================================
Oil Price (WTI): $58.84
Implied Vol (OVX): 36.30%
--------------------
Momentum Signal: BEARISH
Carry (Structure): TIGHT/BACKWARDATION
--------------------
RAW SIGNAL STRENGTH: 0.20
FINAL POSITION SIZE: 0.35 (34.6%)
========================================
## ⚠️ Disclaimer
Educational Use Only. This software is for research and testing purposes. It is not financial advice. Trading commodities involves substantial risk of loss.
Based on concepts from "How Does Algorithmic Oil Trading Work?" by Quant Insider.