PEN-TEST-004 — Phase 11b stock backtest (5 detection scenarios)¶
| Field | Value |
|---|---|
| Test ID | PEN-TEST-004 |
| Date | 2026-05-11 |
| Strategy | PEN-STOCK-001 |
| Cohorts consumed | DET-BASELINE-2026-05-11, DET-V1-2026-05-11, DET-V2-2026-05-11, DET-V3-2026-05-11, DET-V4-2026-05-11 |
| Status | complete |
Purpose¶
Stock-only backtest of the PEN-STOCK-001 strategy (scaled exit: Leg 1 +15 % half-exit, 3 % trail, –7 % hard stop, 30-day time stop; $500 fixed sizing; regime gate; $0.50 + 5 bp friction) applied identically to each of the five detection cohorts from PEN-TEST-001 / -002 / -003. Isolates the detection effect — same strategy mechanics, different event populations.
Method¶
backtest.py walks the master calendar in chronological order
per cohort. For each event, the exit fills are pre-resolved by
walking forward-30 trading days at entry time, then the calendar
loop applies cash + regime gating to take entries and book the
pre-computed exits. Equity is marked daily.
Detection events come from the cached cohort parquets — no detection runs were re-executed for this test.
Headline¶
| Cohort | Final equity | Total return | CAGR | Max DD | Sharpe | Trades | Skipped no-cash | Win rate |
|---|---|---|---|---|---|---|---|---|
| DET-BASELINE | $40,398 | +304 % | 7.50 % | −38.1 % | 0.543 | 8,842 | 6,573 | 43.7 % |
| DET-V1 | $30,858 | +209 % | 6.01 % | −20.4 % | 0.609 | 4,533 | 591 | 45.1 % |
| DET-V2 | $35,651 | +257 % | 6.80 % | −21.4 % | 0.617 | 6,108 | 1,272 | 44.7 % |
| DET-V3 | $31,240 | +212 % | 6.08 % | −32.3 % | 0.547 | 5,200 | 1,070 | 45.0 % |
| DET-V4 | $28,615 | +186 % | 5.59 % | −21.2 % | 0.580 | 4,101 | 511 | 45.4 % |
Baseline wins on absolute compounding (trade count × $500 per trade); V2 wins on risk-adjusted compounding (best Sharpe, half the drawdown).
Files in this directory¶
backtest.py— backtest driver (PEN-STOCK-001 spec embedded in module docstring + constants, lines 1–44)plot_backtest.py— generates the equity-curve PNG + EOY CSVbacktest.log,backtest.stdout.log— run logsbacktest_summary.json— headline JSON for downstream toolingbacktest_eoy.csv— end-of-year equity table (5 scenarios)backtest_equity_<cohort>.parquet× 5 — daily equity time series per cohortbacktest_trades_<cohort>.parquet× 5 — full per-trade ledger per cohortreport.md→../../reports/Pennant/pennant_strategy_backtest_2026-05-11.md- Chart (referenced by report):
../../charts/Pennant/pennant_strategy_backtest_equity_curves_2026-05-11.png
Related findings¶
- F-004 — Baseline maximizes raw return; V2 maximizes risk-adjusted return; trade-count × average-profit moves the equity curve, not win rate.
Reproducer¶
cd /home/kungfujones/Projects/Uriel/build_v1 && source .venv/bin/activate
cd /home/kungfujones/Projects/Uriel/Pennant
python tests/2026-05-11_PEN-TEST-004/backtest.py
The script reads its SCENARIOS dict from backtest.py:46-52,
which currently points at *_events.parquet relative to the
script's directory. To re-run against the canonical cohort
locations (cohorts/DET-X-2026-05-11/events.parquet), the
SCENARIOS dict needs updating — or the harness can be lifted
into infra/simulators/stock_scaled_exit.py to take cohort IDs
directly. Documented as future work in infra/README.md.