feat(manifold): audit matching quality with ManifoldMatchResult and manifold_match_audit table
CI/CD / build-and-push (push) Successful in 14s
CI/CD / build-and-push (push) Successful in 14s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -168,6 +168,52 @@ ALTER TABLE trades ADD COLUMN IF NOT EXISTS feat_btc_dom_lo DOUBLE PRECISION;
|
||||
CREATE INDEX IF NOT EXISTS idx_trades_feat_fg ON trades(feat_fg_lo) WHERE feat_fg_lo IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_trades_feat_mfld ON trades(feat_mfld_lo) WHERE feat_mfld_lo IS NOT NULL;
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- Manifold match audit — per-trade columns in trades
|
||||
--
|
||||
-- Persisted for every trade where Manifold was queried (status='accepted').
|
||||
-- mfld_match_status: 'accepted' | 'rejected' | 'no_results'
|
||||
-- mfld_inverted: TRUE when prob_final = 1 - prob_raw (party complement match)
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_market_id TEXT;
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_market_title TEXT;
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_market_url TEXT;
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_prob_raw DOUBLE PRECISION;
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_prob_final DOUBLE PRECISION;
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_inverted BOOLEAN;
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_match_score DOUBLE PRECISION;
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_match_reason TEXT;
|
||||
ALTER TABLE trades ADD COLUMN IF NOT EXISTS mfld_match_status TEXT;
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- Manifold match audit table — records every Manifold query attempt
|
||||
--
|
||||
-- Populated for ALL queries: accepted, rejected, and no_results.
|
||||
-- used_in_trade=TRUE is set after executor confirms a trade was executed.
|
||||
-- poly_market_id: Market.id from the Polymarket Market dataclass (never NULL).
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
CREATE TABLE IF NOT EXISTS manifold_match_audit (
|
||||
id TEXT PRIMARY KEY,
|
||||
timestamp TIMESTAMPTZ DEFAULT NOW(),
|
||||
poly_market_id TEXT NOT NULL,
|
||||
poly_question TEXT NOT NULL,
|
||||
search_query TEXT,
|
||||
mfld_market_id TEXT,
|
||||
mfld_market_title TEXT,
|
||||
mfld_market_url TEXT,
|
||||
prob_raw DOUBLE PRECISION,
|
||||
prob_final DOUBLE PRECISION,
|
||||
inverted BOOLEAN DEFAULT FALSE,
|
||||
match_score DOUBLE PRECISION,
|
||||
match_reason TEXT,
|
||||
match_status TEXT NOT NULL,
|
||||
used_in_trade BOOLEAN DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_mfld_audit_timestamp ON manifold_match_audit(timestamp DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_mfld_audit_status ON manifold_match_audit(match_status);
|
||||
CREATE INDEX IF NOT EXISTS idx_mfld_audit_poly_mkt ON manifold_match_audit(poly_market_id);
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- Fix 3: extended metrics_daily columns for DB-computed metrics
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user