diff --git a/backend/signal_engine.py b/backend/signal_engine.py index 16c4529..a5724fb 100644 --- a/backend/signal_engine.py +++ b/backend/signal_engine.py @@ -556,24 +556,49 @@ class SymbolState: else: aux_score = 0 - total_score = direction_score + accel_bonus + crowding_score + fr_score + environment_score + confirmation_score + liq_score + aux_score + # 按策略配置的权重缩放各层分数 + weights = strategy_cfg.get("weights", {}) + w_direction = weights.get("direction", 45) + w_crowding = weights.get("crowding", 20) + w_fr = weights.get("funding_rate", 0) + w_environment = weights.get("environment", 15) + w_confirmation = weights.get("confirmation", 15) + w_liq = weights.get("liquidation", 0) + w_auxiliary = weights.get("auxiliary", 5) + + # 原始评分范围: direction 0~45, crowding 0~20, environment 0~15, confirmation 0~15, auxiliary 0~5 + # FR 0~5 (or -5~5), Liq 0~5 + # 缩放到配置权重 + scaled_direction = round(direction_score / 45 * w_direction) + accel_bonus + scaled_crowding = round(crowding_score / 20 * w_crowding) + scaled_fr = fr_score if w_fr > 0 else 0 # FR already 0~5 range, matches w_fr=5 + scaled_environment = round(environment_score / 15 * w_environment) + scaled_confirmation = round(confirmation_score / 15 * w_confirmation) + scaled_liq = liq_score if w_liq > 0 else 0 # Liq already 0~5 range, matches w_liq=5 + scaled_auxiliary = round(aux_score / 5 * w_auxiliary) + + total_score = scaled_direction + scaled_crowding + scaled_fr + scaled_environment + scaled_confirmation + scaled_liq + scaled_auxiliary + total_score = max(0, min(total_score, 100)) # clamp 0~100 + result["score"] = total_score result["direction"] = direction result["factors"] = { "direction": { - "score": direction_score, + "score": scaled_direction, + "max": w_direction, "cvd_fast": 15 if ((direction == "LONG" and cvd_fast > 0) or (direction == "SHORT" and cvd_fast < 0)) else 0, "cvd_mid": 15 if ((direction == "LONG" and cvd_mid > 0) or (direction == "SHORT" and cvd_mid < 0)) else 0, "p99_flow": 15 if has_aligned_p99 else (10 if not has_adverse_p99 else 0), "accel_bonus": accel_bonus, }, - "crowding": {"score": crowding_score, "long_short_ratio": ls_score, "top_trader_position": top_trader_score}, - "environment": {"score": environment_score, "open_interest_hist": oi_change}, - "confirmation": {"score": confirmation_score}, - "auxiliary": {"score": aux_score, "coinbase_premium": coinbase_premium}, - "funding_rate": {"score": fr_score, "value": funding_rate}, + "crowding": {"score": scaled_crowding, "max": w_crowding, "long_short_ratio": ls_score, "top_trader_position": top_trader_score}, + "environment": {"score": scaled_environment, "max": w_environment, "open_interest_hist": oi_change}, + "confirmation": {"score": scaled_confirmation, "max": w_confirmation}, + "auxiliary": {"score": scaled_auxiliary, "max": w_auxiliary, "coinbase_premium": coinbase_premium}, + "funding_rate": {"score": scaled_fr, "max": w_fr, "value": funding_rate}, "liquidation": { - "score": liq_score, + "score": scaled_liq, + "max": w_liq, "long_usd": liq_data.get("long_usd", 0) if liq_data else 0, "short_usd": liq_data.get("short_usd", 0) if liq_data else 0, }, diff --git a/frontend/app/signals-v52/page.tsx b/frontend/app/signals-v52/page.tsx index 778c4c7..c81acfb 100644 --- a/frontend/app/signals-v52/page.tsx +++ b/frontend/app/signals-v52/page.tsx @@ -39,13 +39,13 @@ interface LatestIndicator { signal: string | null; tier?: "light" | "standard" | "heavy" | null; factors?: { - direction?: { score?: number }; - crowding?: { score?: number }; - environment?: { score?: number }; - confirmation?: { score?: number }; - auxiliary?: { score?: number }; - funding_rate?: { score?: number; value?: number }; - liquidation?: { score?: number; long_usd?: number; short_usd?: number }; + direction?: { score?: number; max?: number }; + crowding?: { score?: number; max?: number }; + environment?: { score?: number; max?: number }; + confirmation?: { score?: number; max?: number }; + auxiliary?: { score?: number; max?: number }; + funding_rate?: { score?: number; max?: number; value?: number }; + liquidation?: { score?: number; max?: number; long_usd?: number; short_usd?: number }; } | null; } @@ -325,13 +325,13 @@ function IndicatorCards({ symbol }: { symbol: Symbol }) {