fix: FR/Liq scoring bugs + compact UI

Backend:
- FR threshold: 0.001→0.0003 (extreme), 0.0003→0.00005 (moderate)
- Liquidation SQL: side='SELL'/'BUY' → 'LONG'/'SHORT' (was never matching!)

Frontend:
- FR/Liq scores now inline in score column (compact)
- Removed bulky green badge buttons from position cards
This commit is contained in:
root 2026-03-01 23:14:07 +00:00
parent 58c72b4d90
commit 7d2bb9f392
3 changed files with 22 additions and 15 deletions

View File

@ -367,8 +367,8 @@ class SymbolState:
cur.execute( cur.execute(
""" """
SELECT SELECT
COALESCE(SUM(CASE WHEN side='SELL' THEN usd_value ELSE 0 END), 0) as long_liq, COALESCE(SUM(CASE WHEN side='LONG' 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='SHORT' THEN usd_value ELSE 0 END), 0) as short_liq
FROM liquidations FROM liquidations
WHERE symbol=%s AND trade_time >= %s WHERE symbol=%s AND trade_time >= %s
""", """,
@ -494,15 +494,15 @@ class SymbolState:
fr_score = 0 fr_score = 0
if "funding_rate" in enabled_signals and funding_rate is not None: if "funding_rate" in enabled_signals and funding_rate is not None:
fr_abs = abs(funding_rate) fr_abs = abs(funding_rate)
if fr_abs >= 0.001: # extreme ±0.1% if fr_abs >= 0.0003: # extreme ±0.03% — 很高的FR逆向减分
# Extreme: penalize if going WITH the crowd # 做多但FR极高多头拥挤= 危险,减分
if (direction == "LONG" and funding_rate > 0.001) or (direction == "SHORT" and funding_rate < -0.001): if (direction == "LONG" and funding_rate > 0) or (direction == "SHORT" and funding_rate < 0):
fr_score = -5 fr_score = -5
else: else:
fr_score = 5 fr_score = 5 # 反向操作,加分
elif fr_abs >= 0.0003: # moderate ±0.03% elif fr_abs >= 0.00005: # moderate ±0.005% — 轻度偏移,顺向加分
# Moderate: reward going AGAINST the crowd # 做多且FR为负空头付钱给多头= 顺势,加分
if (direction == "LONG" and funding_rate < -0.0003) or (direction == "SHORT" and funding_rate > 0.0003): if (direction == "LONG" and funding_rate < 0) or (direction == "SHORT" and funding_rate > 0):
fr_score = 5 fr_score = 5
else: else:
fr_score = 0 fr_score = 0

View File

@ -346,8 +346,7 @@ function ActivePositions({ strategy }: { strategy: StrategyFilter }) {
</div> </div>
{isV52 && ( {isV52 && (
<div className="mt-1 grid grid-cols-2 gap-2 text-[10px] font-semibold"> <div className="mt-1 grid grid-cols-2 gap-2 text-[10px] font-semibold">
<div className="rounded-md bg-emerald-100/70 text-emerald-800 px-2 py-1"> Funding Rate Score: {frScore >= 0 ? "+" : ""}{frScore}</div> {isV52 && <div className="text-[10px] text-emerald-600 mt-0.5">FR {frScore >= 0 ? "+" : ""}{frScore} · Liq {liqScore >= 0 ? "+" : ""}{liqScore}</div>}
<div className="rounded-md bg-cyan-100/70 text-cyan-800 px-2 py-1"> Liquidation Score: {liqScore >= 0 ? "+" : ""}{liqScore}</div>
</div> </div>
)} )}
</div> </div>
@ -525,10 +524,7 @@ function TradeHistory({ strategy }: { strategy: StrategyFilter }) {
</span> </span>
</td> </td>
<td className="px-2 py-1.5 text-right font-mono"> <td className="px-2 py-1.5 text-right font-mono">
<div>{t.score}</div> <div>{t.score}{isV52 && (frScore !== 0 || liqScore !== 0) ? <span className="text-emerald-600 text-[9px] ml-0.5">({frScore > 0 ? "+" : ""}{frScore}/{liqScore > 0 ? "+" : ""}{liqScore})</span> : ""}</div>
<div className={`text-[9px] ${isV52 ? "text-emerald-600 font-semibold" : "text-slate-400"}`}>
{isV52 ? `✨ FR ${frScore >= 0 ? "+" : ""}${frScore} · Liq ${liqScore >= 0 ? "+" : ""}${liqScore}` : "FR/Liq 仅V5.2"}
</div>
</td> </td>
<td className="px-2 py-1.5 text-right text-slate-400">{holdMin}m</td> <td className="px-2 py-1.5 text-right text-slate-400">{holdMin}m</td>
</tr> </tr>

View File

@ -0,0 +1,11 @@
2026-03-01 23:06:35,118 [INFO] signal-engine: 已加载策略配置: v51_baseline, v52_8signals
2026-03-01 23:06:37,990 [INFO] signal-engine: [BTCUSDT] 冷启动完成: 加载425,636条历史数据 (窗口=4h)
2026-03-01 23:06:41,185 [INFO] signal-engine: [ETHUSDT] 冷启动完成: 加载474,707条历史数据 (窗口=4h)
2026-03-01 23:06:41,583 [INFO] signal-engine: [XRPUSDT] 冷启动完成: 加载63,246条历史数据 (窗口=4h)
2026-03-01 23:06:42,041 [INFO] signal-engine: [SOLUSDT] 冷启动完成: 加载70,472条历史数据 (窗口=4h)
2026-03-01 23:06:42,041 [INFO] signal-engine: === Signal Engine (PG) 启动完成 ===
2026-03-01 23:06:42,270 [INFO] signal-engine: [BTCUSDT] 🚨 信号[v51_baseline]: LONG score=90 price=65362.8
2026-03-01 23:06:42,270 [INFO] signal-engine: [BTCUSDT] 🚨 信号[v52_8signals]: LONG score=90 price=65362.8
2026-03-01 23:06:42,726 [INFO] signal-engine: [SOLUSDT] 🚨 信号[v51_baseline]: LONG score=92 price=82.8
2026-03-01 23:06:42,726 [INFO] signal-engine: [SOLUSDT] 🚨 信号[v52_8signals]: LONG score=92 price=82.8
2026-03-01 23:07:14,105 [INFO] signal-engine: 冷启动保护期结束,模拟盘开仓已启用