A Python-based analysis and backtesting framework for the SVIX/VXZ volatility spread strategy with actual position tracking and dynamic beta weighting.
Current Phase: Prototype Analysis Complete Analysis Period: March 30, 2022 - December 31, 2025 (3.74 years, 943 trading days)
✅ Strategy Performance (with actual position tracking):
- Total Return: +8.65% ($100,000 → $108,645)
- CAGR: 2.59% annualized
- Max Drawdown: -17.98% (vs -79% for SVIX alone)
- Sharpe Ratio: -0.123 (negative)
- Rebalances: 117 executed over 3.74 years
📊 See ANALYSIS_RESULTS.md for complete findings
This project implements and validates the SVIX (-1x Short VIX Futures) and VXZ (+1x Mid-term VIX Futures) volatility spread strategy with:
- Actual position tracking (share counts and dollar values)
- Dynamic beta weighting (ratio adjusts based on rolling 6-month beta)
- Drift-triggered rebalancing (10% threshold)
- Realistic performance (accounts for drift between rebalances)
- Comprehensive analytics (yearly breakdowns, rolling metrics)
- Real Data: Yahoo Finance integration via yfinance
- Position Tracking: Actual shares and dollar values (not theoretical weights)
- Dynamic Weighting: Beta-based ratio that changes with market volatility
- Rebalancing Logic: Drift-triggered at 10% threshold (117 rebalances over 3.74 years)
- Performance Metrics: CAGR, Sharpe, Sortino, Max Drawdown
- Visualizations: 4-panel dashboard with cumulative returns, beta, drift, and drawdown
- Validation: Comparison with theoretical calculations and Gemini claims
- SVIX: -1x Short VIX Short-Term Futures ETF (Volatility Shares)
- VXZ: Mid-Term VIX Futures ETN (Barclays iPath)
- Strategy: Long both in a beta-weighted ratio (~2:1 VXZ:SVIX based on actual data)
- Python 3.8 or higher
- Git
- API keys for market data sources (optional but recommended)
git clone <repository-url>
cd vol_etf_strat# The virtual environment is already included
# Activate it:
# On Windows (Git Bash/MINGW64):
. venv/Scripts/activate
# On Windows (PowerShell):
venv\Scripts\Activate.ps1
# On Linux/Mac:
source venv/bin/activatepip install -r requirements.txtNote: Installing ta-lib may require additional steps. If you encounter issues, you can use pandas-ta as an alternative (already included in requirements).
# Copy the template
cp .env.template .env
# Edit .env and add your API keys
# Never commit .env to version control!Required environment variables:
ALPHAVANTAGE_API_KEY: Your Alpha Vantage API key (optional)YAHOO_FINANCE_API_KEY: Your Yahoo Finance API key (if required)
vol_etf_strat/
├── src/ # Source code
│ ├── data/ # Data fetching and caching
│ ├── strategies/ # Strategy implementations
│ ├── backtesting/ # Backtesting engine
│ ├── analytics/ # Performance analytics
│ └── reporting/ # Reporting and visualization
├── tests/ # Unit and integration tests
├── notebooks/ # Jupyter notebooks for exploration
├── results/ # Backtest results (not in git)
├── data/ # Cached data (not in git)
├── docs/ # Additional documentation
├── project_spec.md # Detailed project specification
├── architecture.md # System architecture documentation
├── project_status.md # Current project status and milestones
└── README.md # This file
# Activate virtual environment
. venv/Scripts/activate # Windows Git Bash
# OR
venv\Scripts\Activate.ps1 # Windows PowerShell
# Run the SVIX/VXZ analysis
python analyze_svix_vxz.pyOutput:
- Console: Performance metrics, rebalance count, annual breakdown
- File:
svix_vxz_analysis.png(4-panel dashboard)
The script performs:
- Data Download: Fetches SVIX and VXZ from Yahoo Finance (March 2022 - present)
- Rolling Beta: Calculates 126-day (6-month) rolling beta
- Drift Tracking: Monitors actual vs target ratio deviation
- Position Tracking: Real share counts and dollar values
- Rebalancing: Executes when drift exceeds 10% threshold
- Performance Metrics: CAGR, Sharpe, Sortino, Max Drawdown
- Visualization: Generates 4-panel dashboard
============================================================
SVIX/VXZ VOLATILITY ETF SPREAD ANALYSIS
============================================================
Data Download: 2022-03-28 to 2026-01-01
Combined dataset: 943 trading days
Calculating 126-day rolling beta...
-> Average rolling beta: -1.988
-> Beta range: [-2.518, -1.676]
Calculating returns with actual position tracking ($100,000 initial capital)...
-> Final portfolio value: $108,645.40
-> Total return: 8.65%
-> Actual rebalances executed: 117
PERFORMANCE METRICS
Metric SVIX VXZ Portfolio
------------------------------------------------------------
CAGR 14.12% -16.34% 2.59%
Sharpe Ratio 0.495 -0.574 -0.123
Max Drawdown -79.30% -62.05% -17.98%
Dashboard saved to: svix_vxz_analysis.png
Run the yearly breakdown script:
python yearly_analysis.pyOutput (actual results):
- 2022 (Mar-Dec): SVIX -0.88%, VXZ -0.77%
- 2023: SVIX +155.62%, VXZ -43.19% ← Money year
- 2024: SVIX -32.90%, VXZ -12.29% ← Gave back gains
- 2025: SVIX -2.26%, VXZ +5.13%
pytest tests/black src/ tests/
flake8 src/ tests/jupyter notebook- Project Specification: Detailed requirements and goals
- Architecture: System design and component overview
- Project Status: Current progress and milestones
- Changelog: Version history and changes
- CLAUDE.md: Guidance for AI-assisted development
- Never commit API keys or credentials to version control
- Always use
.envfiles for sensitive configuration - The
.gitignoreis configured to exclude sensitive files - Review all commits to ensure no secrets are included
- Expected (from Gemini): -3.2 (SVIX is 3.2x more volatile than VXZ)
- Actual (measured): -1.988 average (range: -1.68 to -2.52)
- Implication: Should use ~2:1 ratio, not 3.2:1
Gemini Claimed (2024-2025):
- Annualized Return: +14.2% to +17.8%
- Max Drawdown: -11.8%
- Sharpe: 0.82 to 1.08
Actual Results (2024-2025):
- SVIX: -35.92%
- VXZ: -7.26%
- Both assets lost money → Claimed returns are impossible
Our Full Analysis (Mar 2022 - Dec 2025):
- Portfolio Return: +8.65%
- CAGR: 2.59%
- Max Drawdown: -17.98%
- Sharpe: -0.123
| Year | SVIX | VXZ | Winner |
|---|---|---|---|
| 2023 | +155% | -43% | Short vol crushed it |
| 2024 | -33% | -12% | Both lost |
| 2025 | -2% | +5% | Slight VXZ edge |
Conclusion: 2023 was the profit year. Strategy has been giving back gains since then.
- Theoretical (always at target): +13.44% total
- Actual (with drift): +8.65% total
- Performance degradation: 35% worse due to drift and rebalancing
See project_status.md for detailed milestones and progress.
Current Phase: Prototype Analysis Complete (45% overall)
- ✅ Project Setup (100%)
- ✅ Data Collection (100%)
- 🟢 Core Backtesting (60% - prototype done)
- 🟢 Strategy Implementation (40% - SVIX/VXZ done)
- ✅ Analytics & Reporting (100%)
- 🟢 Testing & Validation (70% - validated against real data)
- Add transaction cost modeling (0.1-0.2% per trade)
- Test alternative drift thresholds (5%, 15%, 20%)
- Implement regime filtering (only trade in low-VIX contango)
- Compare fixed vs dynamic ratio strategies
- Add more volatility products (VXX, UVXY analysis)
This is currently a personal project. If you'd like to contribute:
- Follow the existing code structure
- Write tests for new features
- Update documentation as needed
- Ensure no sensitive data is committed
This software is for educational and research purposes only. Past performance does not guarantee future results. Trading involves risk. Do not use this system for live trading without thorough testing and understanding of the risks involved.
[To be determined]
[Your contact information]
Last Updated: 2026-01-01 Status: Initial Setup Phase