fix(v7): ensure SHY column exists for profit-take park allocation
V3's output only includes {SPY, TQQQ, UPRO, GLD, DBC}. When PT
triggered, park_col resolved to "" (cash at 0%) instead of SHY.
Now injects SHY column before the PT loop if present in data.
Impact: ~0 in 2016-2026 (rising rates made SHY slightly negative),
but fixes ~0.6%/yr drag in normal rate environments (SHY ~4%/yr,
14.3% of days in PT-park).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -110,6 +110,10 @@ class TrendRiderV7(Strategy):
|
||||
# --- Layer 1: V3 regime weights (already shift(1)'d) ---
|
||||
w = self.v3.generate_signals(data)
|
||||
|
||||
# Ensure pt_park column exists so PT can allocate to it
|
||||
if self.pt_park and self.pt_park in data.columns and self.pt_park not in w.columns:
|
||||
w[self.pt_park] = 0.0
|
||||
|
||||
# --- Layer 2: Vol-target overlay ---
|
||||
daily_ret = data.pct_change(fill_method=None).fillna(0.0)
|
||||
port_rets = (w * daily_ret).sum(axis=1)
|
||||
|
||||
Reference in New Issue
Block a user