Add edge case test for short history in _signal_vix_trend

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-03-21 08:23:47 +00:00
parent 5799bb3f00
commit 433af4d1e4
2 changed files with 8 additions and 2 deletions

View File

@ -86,6 +86,12 @@ class TestSignalVixTrend:
score, desc = self.fn(vix)
assert score == 0
def test_short_history_is_neutral(self):
vix = _make_series([20.0] * 20)
score, desc = self.fn(vix)
assert score == 0
assert "insufficient history" in desc
def test_none_series_is_neutral(self):
score, desc = self.fn(None)
assert score == 0

View File

@ -92,8 +92,8 @@ def _signal_vix_level(vix_price: Optional[float]) -> tuple[int, str]:
def _signal_vix_trend(vix_series: Optional[pd.Series]) -> tuple[int, str]:
"""VIX 5-day SMA vs 20-day SMA: rising VIX = risk-off."""
if vix_series is None:
return 0, "VIX trend: unavailable (neutral)"
if vix_series is None or len(vix_series) < 21:
return 0, "VIX trend: insufficient history (neutral)"
sma5 = _sma(vix_series, 5)
sma20 = _sma(vix_series, 20)
if sma5 is None or sma20 is None: