feat: expand market coverage to politics, tech, and events categories
CI/CD / build-and-push (push) Successful in 1m31s
CI/CD / build-and-push (push) Successful in 1m31s
- polymarket.py: add keyword lists for politics (election, trump, ukraine…), tech (AI, OpenAI, Apple, nvidia…), and events (super bowl, oscar, spacex…); introduce _detect_category() so all four categories flow through a single code path; filter already-expired markets (end_dt < now) in addition to the existing future-cutoff filter; log per-category counts at startup - bayesian.py: extend is_any_supported to include is_politics / is_tech / is_events; use BTC as a risk-sentiment proxy for non-crypto categories (halved weight to reflect weaker correlation); cap confidence_cap at 0.65 for macro/politics/tech/events; MIN_EDGE stays at 0.10 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -66,6 +66,7 @@ class BayesianStrategy:
|
||||
Returns None if no actionable opportunity.
|
||||
"""
|
||||
question_lower = market.question.lower()
|
||||
category = market.category # set by PolymarketClient
|
||||
|
||||
# Classify what kind of market this is
|
||||
is_price_above = any(w in question_lower for w in ["above", "over", "exceed", "higher", "atleast", "reach"])
|
||||
@@ -85,8 +86,14 @@ class BayesianStrategy:
|
||||
is_macro = any(
|
||||
w in question_lower for w in ["nasdaq", "s&p", "sp500", "inflation", "fed rate", "interest rate", "tariff"]
|
||||
)
|
||||
is_politics = category == "politics"
|
||||
is_tech = category == "tech"
|
||||
is_events = category == "events"
|
||||
|
||||
is_any_supported = is_btc or is_eth or is_altcoin or is_general_crypto or is_macro
|
||||
is_any_supported = (
|
||||
is_btc or is_eth or is_altcoin or is_general_crypto or is_macro
|
||||
or is_politics or is_tech or is_events
|
||||
)
|
||||
if not is_any_supported:
|
||||
log.debug("Skipping unsupported market: %s", market.question[:60])
|
||||
return None
|
||||
@@ -103,12 +110,17 @@ class BayesianStrategy:
|
||||
adjustments: list[float] = []
|
||||
|
||||
# Signal 1: Price momentum (asset-specific or total market cap as proxy)
|
||||
# For politics/tech/events use BTC as a broad sentiment proxy.
|
||||
if is_btc:
|
||||
momentum = ext.btc_change_24h
|
||||
asset_label = "BTC"
|
||||
elif is_eth:
|
||||
momentum = ext.eth_change_24h
|
||||
asset_label = "ETH"
|
||||
elif is_politics or is_tech or is_events:
|
||||
# BTC as risk-sentiment proxy for non-crypto categories
|
||||
momentum = ext.btc_change_24h
|
||||
asset_label = "BTC(sentiment)"
|
||||
else:
|
||||
# Altcoins and general crypto: use total market cap change as proxy
|
||||
momentum = ext.total_market_cap_change
|
||||
@@ -116,6 +128,9 @@ class BayesianStrategy:
|
||||
|
||||
if abs(momentum) > 2:
|
||||
momentum_adj = math.tanh(momentum / 20) * 0.15 # Max ±15%
|
||||
# For non-directional markets (politics/events/tech), momentum is weaker signal
|
||||
if is_politics or is_tech or is_events:
|
||||
momentum_adj *= 0.5
|
||||
adjustments.append(momentum_adj if is_price_above else -momentum_adj)
|
||||
sources.append(f"{asset_label} 24h: {momentum:+.1f}%")
|
||||
|
||||
@@ -143,9 +158,11 @@ class BayesianStrategy:
|
||||
adjustments.append(dom_adj)
|
||||
sources.append(f"BTC dom: {ext.btc_dominance:.1f}% (low → alt season)")
|
||||
|
||||
# Macro markets: lower weight, rely only on Fear&Greed signal already added
|
||||
# Cap confidence below for macro to reflect weaker signal quality
|
||||
confidence_cap = 0.70 if is_macro else 0.90
|
||||
# Macro/politics/tech/events: cap confidence lower to reflect weaker signal quality
|
||||
if is_macro or is_politics or is_tech or is_events:
|
||||
confidence_cap = 0.65
|
||||
else:
|
||||
confidence_cap = 0.90
|
||||
|
||||
# Compute posterior using log-odds updating
|
||||
log_odds_prior = math.log(prior / (1 - prior))
|
||||
|
||||
Reference in New Issue
Block a user