fix(strategy): exclude momentum and fear-greed signals from non-price markets (politics/tech/events)
CI/CD / build-and-push (push) Successful in 7s
CI/CD / build-and-push (push) Successful in 7s
For politics/tech/events markets there is no above/below price notion, so is_price_above defaulted to False (or flipped on accidental wording like "reach") and sign-inverted the macro adjustments: BTC +5% or high Fear&Greed subtracted probability from YES on "Will X win the election?" markets. Skip both signals entirely for non-price markets: contributions stay 0.0, feat_mom_lo / feat_fg_lo persist as 0.0. Price markets (BTC/ETH/crypto) keep the exact current behavior, including the below-market sign flip. Removes the now-dead BTC(sentiment) momentum branch and its 0.5 attenuator. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
96f31acf16
commit
4002f03d0c
+39
-33
@@ -419,42 +419,48 @@ class BayesianStrategy:
|
||||
sources: list[str] = [f"Prior=poly({prior:.3f})"]
|
||||
adjustments: list[float] = []
|
||||
|
||||
# Signal 1: price momentum (asset-specific or BTC as 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:
|
||||
momentum = ext.btc_change_24h
|
||||
asset_label = "BTC(sentiment)"
|
||||
else:
|
||||
momentum = ext.total_market_cap_change
|
||||
asset_label = "total mktcap"
|
||||
# Momentum and Fear & Greed only make sense for price markets, where
|
||||
# is_price_above gives the adjustment a meaningful sign. For
|
||||
# politics/tech/events there is no above/below notion — is_price_above
|
||||
# defaults to False (or flips on accidental wording like "reach"), so
|
||||
# applying these signals just injected sign noise. Skip them entirely;
|
||||
# their contributions stay 0.0 → feat_mom_lo / feat_fg_lo = 0.0.
|
||||
is_non_price = is_politics or is_tech or is_events
|
||||
|
||||
# Signal 1: price momentum (asset-specific; price markets only)
|
||||
_momentum_contribution = 0.0
|
||||
if abs(momentum) > 2:
|
||||
momentum_adj = math.tanh(momentum / 20) * 0.15
|
||||
if is_politics or is_tech or is_events:
|
||||
momentum_adj *= 0.5
|
||||
_momentum_contribution = momentum_adj if is_price_above else -momentum_adj
|
||||
adjustments.append(_momentum_contribution)
|
||||
sources.append(f"{asset_label} 24h: {momentum:+.1f}%")
|
||||
if not is_non_price:
|
||||
if is_btc:
|
||||
momentum = ext.btc_change_24h
|
||||
asset_label = "BTC"
|
||||
elif is_eth:
|
||||
momentum = ext.eth_change_24h
|
||||
asset_label = "ETH"
|
||||
else:
|
||||
momentum = ext.total_market_cap_change
|
||||
asset_label = "total mktcap"
|
||||
|
||||
# Signal 2: Fear & Greed
|
||||
fg = ext.fear_greed_index
|
||||
if fg > 70:
|
||||
fg_adj = 0.06
|
||||
sources.append(f"Fear&Greed: {fg} (greed)")
|
||||
elif fg < 30:
|
||||
fg_adj = -0.06
|
||||
sources.append(f"Fear&Greed: {fg} (fear)")
|
||||
else:
|
||||
fg_adj = (fg - 50) / 50 * 0.04
|
||||
sources.append(f"Fear&Greed: {fg} (neutral)")
|
||||
_fg_contribution = fg_adj if is_price_above else -fg_adj
|
||||
adjustments.append(_fg_contribution)
|
||||
if abs(momentum) > 2:
|
||||
momentum_adj = math.tanh(momentum / 20) * 0.15
|
||||
_momentum_contribution = momentum_adj if is_price_above else -momentum_adj
|
||||
adjustments.append(_momentum_contribution)
|
||||
sources.append(f"{asset_label} 24h: {momentum:+.1f}%")
|
||||
|
||||
# Signal 2: Fear & Greed (price markets only)
|
||||
_fg_contribution = 0.0
|
||||
if not is_non_price:
|
||||
fg = ext.fear_greed_index
|
||||
if fg > 70:
|
||||
fg_adj = 0.06
|
||||
sources.append(f"Fear&Greed: {fg} (greed)")
|
||||
elif fg < 30:
|
||||
fg_adj = -0.06
|
||||
sources.append(f"Fear&Greed: {fg} (fear)")
|
||||
else:
|
||||
fg_adj = (fg - 50) / 50 * 0.04
|
||||
sources.append(f"Fear&Greed: {fg} (neutral)")
|
||||
_fg_contribution = fg_adj if is_price_above else -fg_adj
|
||||
adjustments.append(_fg_contribution)
|
||||
|
||||
# Signal 3: BTC dominance — hurts altcoins when high
|
||||
_btc_dom_contribution = 0.0
|
||||
|
||||
Reference in New Issue
Block a user