feat(phase6): per-feature signal attribution in log-odds space
CI/CD / build-and-push (push) Successful in 1m56s
CI/CD / build-and-push (push) Successful in 1m56s
Adds feat_fg_lo / feat_mom_lo / feat_news_lo / feat_mfld_lo / feat_btc_dom_lo to every trade, all normalized to log-odds contribution for direct comparability. - fg / mom / btc_dom: raw probability-delta × 2 → log-odds - news / mfld: already log-odds (LOGODDS_WEIGHT already applied), no scaling - btc_dom tracked separately in bayesian.py instead of bundled in total_adj - reasoning string updated to fg_lo= / mom_lo= notation for self-documentation Schema: 5 new DOUBLE PRECISION columns + 2 partial indexes Stack: TradingSignal → Order → Trade → save_trade all carry feat fields Startup: backfill_feature_columns() recovers fg/mom/news/mfld from old reasoning strings (×2 applied to fg/mom); btc_dom_lo stays NULL for legacy API: /api/metrics/features — triggered/material split per feature with two-level thresholds (0.05 for fg/mom/btc_dom, 0.10 for news/mfld) API: /api/trades/legacy — exposes pre-Phase-1 trades (edge_net IS NULL) API: _enrich_trade backward-compat: reads DB columns first, falls back to reasoning regex with unit conversion for pre-Phase-6 trades Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,12 @@ class Trade:
|
||||
commission: float = 0.0 # = POLYMARKET_FEE * size_usdc
|
||||
# ── Phase 2: market family ────────────────────────────────────────────────
|
||||
family_key: str = ""
|
||||
# ── Phase 6: per-feature log-odds contributions ───────────────────────────
|
||||
feat_fg_lo: float = 0.0
|
||||
feat_mom_lo: float = 0.0
|
||||
feat_news_lo: float = 0.0
|
||||
feat_mfld_lo: float = 0.0
|
||||
feat_btc_dom_lo: float = 0.0
|
||||
|
||||
def __str__(self) -> str:
|
||||
return (
|
||||
@@ -148,6 +154,12 @@ class PaperExecutor:
|
||||
commission=commission,
|
||||
# Phase 2 family
|
||||
family_key=order.family_key,
|
||||
# Phase 6 feature log-odds
|
||||
feat_fg_lo=order.feat_fg_lo,
|
||||
feat_mom_lo=order.feat_mom_lo,
|
||||
feat_news_lo=order.feat_news_lo,
|
||||
feat_mfld_lo=order.feat_mfld_lo,
|
||||
feat_btc_dom_lo=order.feat_btc_dom_lo,
|
||||
)
|
||||
|
||||
# Update paper portfolio
|
||||
|
||||
Reference in New Issue
Block a user