diff --git a/frontend/app/signals/page.tsx b/frontend/app/signals/page.tsx index b7efa9a..a23e32c 100644 --- a/frontend/app/signals/page.tsx +++ b/frontend/app/signals/page.tsx @@ -48,7 +48,7 @@ interface LatestIndicator { } interface MarketIndicatorValue { - value: number; + value: Record; ts: number; } @@ -115,32 +115,41 @@ function MarketIndicatorsCards({ symbol }: { symbol: Symbol }) { if (!data) return
等待市场指标数据...
; - const ls = Number(data.long_short_ratio?.value ?? 1); - const top = Number(data.top_trader_position?.value ?? 0.5); - const oi = Number(data.open_interest_hist?.value ?? 0); - const premium = Number(data.coinbase_premium?.value ?? 0); + // value是JSONB对象,需要取具体字段 + const lsVal = data.long_short_ratio?.value as Record | undefined; + const topVal = data.top_trader_position?.value as Record | undefined; + const oiVal = data.open_interest_hist?.value as Record | undefined; + const premVal = data.coinbase_premium?.value as Record | undefined; + + const longPct = Number(lsVal?.longAccount ?? 0.5) * 100; + const shortPct = Number(lsVal?.shortAccount ?? 0.5) * 100; + const topLong = Number(topVal?.longAccount ?? 0.5) * 100; + const topShort = Number(topVal?.shortAccount ?? 0.5) * 100; + const oiValue = Number(oiVal?.sumOpenInterestValue ?? 0); + const oiDisplay = oiValue >= 1e9 ? `$${(oiValue / 1e9).toFixed(2)}B` : oiValue >= 1e6 ? `$${(oiValue / 1e6).toFixed(0)}M` : `$${oiValue.toFixed(0)}`; + const premium = Number(premVal?.premium_pct ?? 0); return (

多空比 (L/S)

-

Long: {(ls / (1 + ls) * 100).toFixed(1)}%

-

Short: {(100 - (ls / (1 + ls) * 100)).toFixed(1)}%

+

Long: {longPct.toFixed(1)}%

+

Short: {shortPct.toFixed(1)}%

大户持仓

-

大户做多: {(top * 100).toFixed(1)}%

-

方向: {top >= 0.55 ? "多头占优" : top <= 0.45 ? "空头占优" : "中性"}

+

大户做多: {topLong.toFixed(1)}%

+

方向: {topLong >= 55 ? "多头占优" : topLong <= 45 ? "空头占优" : "中性"}

-

OI变化

-

{pct(oi, 2)}

-

活跃度: {oi >= 0.03 ? "高" : oi > 0 ? "中" : "低"}

+

持仓量 (OI)

+

{oiDisplay}

+

{Number(oiVal?.sumOpenInterest ?? 0).toFixed(0)} BTC

Coinbase Premium

-

= 0 ? "text-emerald-600" : "text-red-500"}`}>{premium >= 0 ? "+" : ""}{pct(premium, 2)}

-

机构: {premium > 0.0005 ? "偏多" : premium < -0.0005 ? "偏空" : "中性"}

+

= 0 ? "text-emerald-600" : "text-red-500"}`}>{premium >= 0 ? "+" : ""}{premium.toFixed(4)}%

+

机构: {premium > 0.005 ? "偏多" : premium < -0.005 ? "偏空" : "中性"}

); @@ -262,11 +271,11 @@ function IndicatorCards({ symbol }: { symbol: Symbol }) {
- - - - - + + + + +
{data.signal && (