RecessionAlert TRENDEX SP-500 — exploratory proxy campaign¶
This executed notebook reads only the checked-in data/market.sqlite cache in read-only mode. The SHA-pinned RecessionAlert article describes support/resistance trend duration and historical reversal probabilities but provides no source-linked TRENDEX values, formula, STOP construction, recurring release timestamp, or portfolio rule. Every score below is an inferred public proxy, not native TRENDEX.
Causal policy: score observations are available only after their dated bar; default execution uses one available-bar lag. The zero-lag run is a timing sensitivity and is not causal.
import json
import sys
sys.path.insert(0, "/home/user/quantmodel-w1")
import pandas as pd
from research.research_campaign.recessionalert_1349 import load_market_close, evaluate_default_variants
from research.lab.metrics import compute_metrics
price = load_market_close("SPY")
spy_ret = price.pct_change(fill_method=None).rename("spy")
ief_ret = load_market_close("IEF").pct_change(fill_method=None).rename("ief")
variants = evaluate_default_variants(price)
rows = []
for variant in variants:
frame = pd.concat([spy_ret, ief_ret, variant["risk_off"].rename("risk_off")], axis=1).dropna()
returns = frame["risk_off"] * frame["ief"] + (1 - frame["risk_off"]) * frame["spy"]
metrics = compute_metrics(returns.tolist(), periods_per_year=252, active=(1 - frame["risk_off"]).tolist())
rows.append({"variant_id": variant["id"], "family": variant["family"], "lag_bars": variant["parameters"]["lag_bars"], "n_bars": len(frame), "cagr": metrics["cagr"], "sharpe": metrics["sharpe"], "max_drawdown": metrics["max_drawdown"], "risk_on_exposure": metrics["exposure"]})
print(json.dumps({"source_sha256": "sha256:0847fa3d8bd7a9dc74a9e07e000ec338362ad84c743b57d710fab8f5d4b8119c", "proxy_history": "SPY 1993-01-29/2026-07-24", "overlay_window": "SPY/IEF 2002-07-31/2026-07-24", "variants": rows}, indent=2, sort_keys=True))
Interpretation¶
The two-bar breakout analogue had the highest causal Sharpe in this small grid, but it is likely generic trend timing and does not validate the source's STOP or empirical probability mapping. The channel-rank and SMA contrast variants traded return for drawdown. Same-close sensitivity was dramatically different, demonstrating why the article's unknown release timing cannot be silently treated as same-close.
No native TRENDEX indicator is registered. Follow-up work would require a separately authorized source refresh with source-linked observations, exact formula, point-in-time availability, and action semantics.