| name | macro-calendar-modulation |
| description | CPI/GDP/retail sales date awareness and VIX regime scaling for calendar features |
| author | Claude Code |
| date | "2026-02-24T00:00:00.000Z" |
| version | 4.4.0 |
Macro Calendar Modulation
Experiment Overview
| Item | Details |
|---|
| Date | 2026-02-24 |
| Goal | Add CPI/GDP/retail sales awareness and VIX regime scaling to calendar features without changing obs_dim |
| Environment | Python 3.11+, OpenBB FRED provider |
| Status | Success |
Context
Calendar features only knew FOMC + employment first Friday. No VIX level, no CPI/GDP dates. Earnings cause 5-10% average moves; CPI/GDP releases move markets significantly.
Design constraint: NUM_FEATURES must stay at 7 (no obs_dim change). Solution: modulate existing hour_weight value.
Implementation
Macro Event Dates
CPI_RELEASE_DATES = [datetime(2024,1,11), datetime(2024,2,13), ...]
GDP_RELEASE_DATES = [datetime(2024,1,25), datetime(2024,2,28), ...]
RETAIL_SALES_DATES = [datetime(2024,1,17), datetime(2024,2,15), ...]
ALL_MACRO_EVENT_DATES = sorted(set(CPI + GDP + RETAIL))
hour_weight Modulation
CalendarFeatureCalculator(enable_macro_modulation=True)
base_weight = ...
if enable_macro_modulation:
if ts_date in self._macro_event_dates:
base_weight *= 1.20
vix_scale = _get_vix_regime_scale()
base_weight *= vix_scale
VIX Regime Scaling
| VIX Level | Scale | Rationale |
|---|
| < 15 | 1.0x | Normal volatility |
| 15-25 | 0.95x | Slightly reduce weight (elevated but manageable) |
| 25-35 | 1.1x | Higher volatility = more signal in price moves |
| > 35 | 1.3x | Panic = high weight (big moves, high importance) |
Caching
- Module-level
_macro_data_cache dict (not instance-level)
- VIX cached for 4 hours via
_fetch_vix_level() using OpenBB FRED
_macro_event_dates pre-built as set in __init__ for O(1) lookup
Failed Attempts
| Attempt | Why it Failed | Lesson Learned |
|---|
| Adding new feature (earnings_proximity) | Changes obs_dim from 5900 to 6000, breaks all existing models | Modulate existing features instead |
| Instance-level VIX cache | Multiple CalendarFeatureCalculator instances waste API calls | Module-level cache shared across instances |
Final Parameters
MACRO_EVENT_BOOST = 1.20
VIX_REGIME_SCALES = {
'normal': 1.0,
'elevated': 0.95,
'high': 1.1,
'panic': 1.3,
}
VIX_CACHE_TTL = 14400
Files Modified
| File | Change |
|---|
alpaca_trading/features/calendar_features.py | Added date lists, _fetch_vix_level(), _is_macro_event_day(), _get_vix_regime_scale(), modulated _hour_weight() |
tests/test_openbb_integration.py | 6 tests for macro modulation |