feat: shadow book + shadow-vs-manual performance comparison
The manual paper book only contains trades taken by hand, inside a 20
minute window, on days someone was available. The backtest that validated
this strategy auto-takes the top-ranked qualified setups up to capacity
every session. The forward record was therefore measuring strategy plus
discretion plus availability -- and degrading silently on busy days.
The shadow book closes that gap: it mirrors the backtest's selection rule
(top strategy_rank qualified, up to capacity, 1% fixed-fractional risk)
and shares the manual book's exit policy, so the only difference between
the two books is which setups get taken. Selection ordering reuses the
strategy_rank the scanner already stores rather than recomputing it, so
the two cannot drift apart. It runs as a near-close pipeline step right
after the scan, marking entries at the same prices a human would see.
Gate-reset re-entry state is now scoped per book -- the books diverge as
soon as their entries differ, and each must see only its own stops.
Performance view rewritten around the comparison:
- three series (shadow, manual, SPY) from a new endpoint
- SPY changes from a per-trade cost-basis counterfactual to plain
buy-and-hold %, since one line has to serve two books
- headline stats are R-multiples, not currency: the books size
differently, so only R compares across them
- configurable start date, because the strategy has been revised
repeatedly and pre-cutover trades ran under rules that no longer
exist
Migration 024 also repairs the numeric weekday crons written by 023,
rewriting only rows still holding the broken form so hand-corrected
settings survive. Its literals are inlined because bound parameters
render as NULL under 'alembic upgrade --sql'.
The shadow book is opt-in and writes nothing until enabled. Verify its
first selections match a backtest of that day's cross-section before
trusting any point on the curve.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,6 +84,25 @@ class ScheduleConfigUpdate(BaseModel):
|
||||
schedule_fundamentals_cron: str | None = Field(default=None, max_length=120)
|
||||
|
||||
|
||||
class PerformanceConfigUpdate(BaseModel):
|
||||
"""Window for the Performance comparison.
|
||||
|
||||
``start_date`` is an ISO date, or empty string to show all history. The
|
||||
strategy has been revised repeatedly; pinning a start keeps the shadow-vs-
|
||||
manual comparison inside one configuration instead of averaging across
|
||||
rules that no longer exist.
|
||||
"""
|
||||
start_date: str | None = Field(default=None, max_length=10)
|
||||
|
||||
|
||||
class ShadowBookConfigUpdate(BaseModel):
|
||||
"""Auto-traded shadow book: the validated strategy with no human input."""
|
||||
enabled: bool | None = None
|
||||
capacity: int | None = Field(default=None, ge=1, le=100)
|
||||
risk_pct: float | None = Field(default=None, gt=0, le=10)
|
||||
start_equity: float | None = Field(default=None, ge=1000)
|
||||
|
||||
|
||||
class SentimentConfigUpdate(BaseModel):
|
||||
"""Runtime sentiment LLM config. api_key is write-only; omit/empty to keep
|
||||
the stored key."""
|
||||
|
||||
Reference in New Issue
Block a user