diff --git a/backend/signal_engine.py b/backend/signal_engine.py index dc7eec2..fae313e 100644 --- a/backend/signal_engine.py +++ b/backend/signal_engine.py @@ -367,8 +367,8 @@ class SymbolState: cur.execute( """ SELECT - COALESCE(SUM(CASE WHEN side='SELL' THEN usd_value ELSE 0 END), 0) as long_liq, - COALESCE(SUM(CASE WHEN side='BUY' THEN usd_value ELSE 0 END), 0) as short_liq + COALESCE(SUM(CASE WHEN side='LONG' THEN usd_value ELSE 0 END), 0) as long_liq, + COALESCE(SUM(CASE WHEN side='SHORT' THEN usd_value ELSE 0 END), 0) as short_liq FROM liquidations WHERE symbol=%s AND trade_time >= %s """, @@ -494,15 +494,15 @@ class SymbolState: fr_score = 0 if "funding_rate" in enabled_signals and funding_rate is not None: fr_abs = abs(funding_rate) - if fr_abs >= 0.001: # extreme ±0.1% - # Extreme: penalize if going WITH the crowd - if (direction == "LONG" and funding_rate > 0.001) or (direction == "SHORT" and funding_rate < -0.001): + if fr_abs >= 0.0003: # extreme ±0.03% — 很高的FR,逆向减分 + # 做多但FR极高(多头拥挤)= 危险,减分 + if (direction == "LONG" and funding_rate > 0) or (direction == "SHORT" and funding_rate < 0): fr_score = -5 else: - fr_score = 5 - elif fr_abs >= 0.0003: # moderate ±0.03% - # Moderate: reward going AGAINST the crowd - if (direction == "LONG" and funding_rate < -0.0003) or (direction == "SHORT" and funding_rate > 0.0003): + fr_score = 5 # 反向操作,加分 + elif fr_abs >= 0.00005: # moderate ±0.005% — 轻度偏移,顺向加分 + # 做多且FR为负(空头付钱给多头)= 顺势,加分 + if (direction == "LONG" and funding_rate < 0) or (direction == "SHORT" and funding_rate > 0): fr_score = 5 else: fr_score = 0 diff --git a/frontend/app/paper/page.tsx b/frontend/app/paper/page.tsx index fceecb8..ee55560 100644 --- a/frontend/app/paper/page.tsx +++ b/frontend/app/paper/page.tsx @@ -346,8 +346,7 @@ function ActivePositions({ strategy }: { strategy: StrategyFilter }) { {isV52 && (