python cli.py state-variablesThis calculates the 7 economic state variables:
- Market level (log S&P 500)
- Yield curve (10Y - 3M spread)
- Oil price (WTI)
- Copper price
- Monetary policy (3M T-bill)
- Volatility (realized vol / VIX)
- Stock-bond correlation
Output: Raw data, z-scores, and winsorized data saved to cache/ directory.
python cli.py factor-returnsThis downloads and processes factor return data from various sources.
Output: Factor return data saved to cache/ directory.
python cli.py similarity-scoreThis calculates similarity scores between different time periods based on the state variables.
Output: Similarity scores saved to cache/ directory.
python cli.py backtestThis runs the main backtesting engine for the regime-based factor strategy.
Output: Backtest results and performance metrics saved to cache/ directory.
To analyze similar periods to a specific date:
-
Edit the configuration:
- Open
config.yaml - Change
similarity_score.mask_horizonfrom36to0 - Change
similar_periods.target_monthto your desired date (e.g.,"2022-01")
- Open
-
Re-run similarity score:
python cli.py similarity-score
-
Run similar periods analysis:
python cli.py similar-periods
Output: Visualization of similar periods saved to reports/ directory.
You can customize parameters by editing config.yaml or using command-line arguments:
# Example: Run backtest with custom parameters
python cli.py backtest --start-date 1990-01-31 --vol-target 0.12 --n-buckets 5
# Example: Find similar periods for a specific month
python cli.py similar-periods --target-month 2008-10
# Example: Save configuration snapshots
python cli.py state-variables --save-config my_config- Cache Directory (
cache/): Contains processed data files (.pklformat) - Reports Directory (
reports/): Contains generated visualizations and charts - Data Directory (
data/): Contains raw input data files
- Ensure all required data files are present in the
data/directory - Verify internet connection for downloading FRED and yfinance data
- If you encounter memory issues, consider reducing the date range in
config.yaml