From 324edbe4c81b5bf6954a646594e71ccab807fab5 Mon Sep 17 00:00:00 2001 From: chemavx Date: Tue, 14 Apr 2026 13:03:49 +0000 Subject: [PATCH] feat(polymarket): exclude sports markets before category detection Add _SPORTS_EXCLUSIONS list checked first in _detect_category so NBA/NFL/ MLB/NHL/tennis/golf/UFC/boxing/wrestling/tournament markets never bleed into politics or events categories. Also removes 'super bowl' from _EVENTS_KEYWORDS since it's now covered by the sports exclusion. Keywords excluded: nba, nfl, mlb, nhl, basketball, football, baseball, hockey, soccer, mvp, rookie of the, championship, super bowl, world series, playoffs, playoff, tournament, tennis, golf, ufc, boxing, wrestler, wrestling, slam dunk, home run, touchdown. Co-Authored-By: Claude Sonnet 4.6 --- bot/data/polymarket.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bot/data/polymarket.py b/bot/data/polymarket.py index dc8eef9..8eb957b 100644 --- a/bot/data/polymarket.py +++ b/bot/data/polymarket.py @@ -82,9 +82,25 @@ class PolymarketClient: ] _EVENTS_KEYWORDS: list[str] = [ - "super bowl", "world cup", "oscar", "nobel", "spacex", "nasa", + "world cup", "oscar", "nobel", "spacex", "nasa", ] + # Sports markets are excluded entirely — BTC/F&G/GNews have no edge there. + # Checked before any category match so sports don't bleed into politics/events. + _SPORTS_EXCLUSIONS: list[str] = [ + " nba ", " nfl ", " mlb ", " nhl ", + "basketball", "football", "baseball", "hockey", "soccer", + " mvp ", "rookie of the", "championship", "super bowl", "world series", + "playoffs", "playoff", "tournament", + "tennis", " golf ", " ufc ", "boxing", "wrestler", "wrestling", + "slam dunk", "home run", "touchdown", + ] + + @classmethod + def _is_sports(cls, question: str) -> bool: + q = f" {question.lower()} " + return any(kw in q for kw in cls._SPORTS_EXCLUSIONS) + @classmethod def _is_crypto_finance(cls, question: str) -> bool: q = f" {question.lower()} " # pad so edge keywords match cleanly @@ -108,6 +124,8 @@ class PolymarketClient: @classmethod def _detect_category(cls, question: str) -> str: """Return the category label for a market question, or '' if unsupported.""" + if cls._is_sports(question): + return "" # exclude sports regardless of other keyword matches if cls._is_crypto_finance(question): return "crypto/finance" if cls._is_politics(question):