From df988a36b600cd907509f624902574d4fe407a9d Mon Sep 17 00:00:00 2001 From: chemavx Date: Tue, 2 Jun 2026 09:06:06 +0000 Subject: [PATCH] fix(metrics): exclude excluded_from_metrics trades from trades_dominated_by_mfld counter The trades_dominated_by_mfld counter omitted the excluded_from_metrics filter, so the admin-closed Maine governor trade inflated it to 1 while attribution/features (which exclude such trades) were empty. Add excluded_from_metrics IS NOT TRUE and mfld_match_status = 'accepted' to the query so the counter is consistent with the attribution and feature-metrics endpoints. Co-Authored-By: Claude Opus 4.8 (1M context) --- api/main.py | 4 +++- bot/data/db.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/main.py b/api/main.py index 439246e..f72e092 100644 --- a/api/main.py +++ b/api/main.py @@ -223,7 +223,9 @@ async def get_manifold_matches(): summary.all_time — accepted/rejected/no_results across every matcher version. summary.legacy.accepted_without_outcome_type — pre-outcome-guard accepted records that the current matcher would reject (not counted in current_version). - summary.trades_dominated_by_mfld — open trades where feat_mfld_lo is the largest signal. + summary.trades_dominated_by_mfld — non-excluded accepted-match trades where + feat_mfld_lo is the largest signal (consistent with attribution/features, + which also exclude excluded_from_metrics trades). recent_matches: last 50 rows from manifold_match_audit, newest first, each tagged with matcher_version. diff --git a/bot/data/db.py b/bot/data/db.py index 73a1bef..0ac20f0 100644 --- a/bot/data/db.py +++ b/bot/data/db.py @@ -594,7 +594,9 @@ class Database: """) mfld_dominated = await conn.fetchrow(""" SELECT COUNT(*) AS cnt FROM trades - WHERE feat_mfld_lo IS NOT NULL + WHERE (excluded_from_metrics IS NOT TRUE) + AND mfld_match_status = 'accepted' + AND feat_mfld_lo IS NOT NULL AND ABS(feat_mfld_lo) > 0.0001 AND ABS(feat_mfld_lo) > ABS(COALESCE(feat_fg_lo, 0)) AND ABS(feat_mfld_lo) > ABS(COALESCE(feat_mom_lo, 0))