From 57344d33f71f2bca9e6b96af1a7897a61ed062d9 Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Sun, 3 May 2026 19:11:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(dashboard):=20current=20spread=20sign=20for?= =?UTF-8?q?=20HL=E2=86=92BG=20positions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: current spread always computed as (hl-bg)/bg regardless of position direction. For HL→BG positions, spread should be (bg-hl)/hl to match entry spread convention. Fix: check LongLeg.Exchange — if HL→BG, use (bg-hl)/hl instead. --- dashboard.go | 4 ++++ web/static/app.js | 4 ++++ web/static/style.css | 1 + 3 files changed, 9 insertions(+) diff --git a/dashboard.go b/dashboard.go index c729cf5..2434cc0 100644 --- a/dashboard.go +++ b/dashboard.go @@ -323,6 +323,10 @@ func (d *Dashboard) broadcastLoop() { netPnl := longPnl + shortPnl - totalFees currentSpread := (hlP - bgP) / bgP * 100 + if pos.LongLeg.Exchange == ExHyperLiquid { + // HL→BG: spread positive when bgP > hlP + currentSpread = (bgP - hlP) / hlP * 100 + } posEntry["current_spread"] = math.Round(currentSpread*10000) / 10000 posEntry["pnl_est"] = math.Round(netPnl*10000) / 10000 } diff --git a/web/static/app.js b/web/static/app.js index 3669520..9f835f6 100644 --- a/web/static/app.js +++ b/web/static/app.js @@ -603,6 +603,10 @@ document.addEventListener('keydown', function(e) { if (e.key === 'Escape') closeTradeDetail(); }); +// Expose modal functions to global scope for HTML onclick handlers +window.openTradeDetail = openTradeDetail; +window.closeTradeDetail = closeTradeDetail; + // ---- Init ---- function init() { connectSSE(); diff --git a/web/static/style.css b/web/static/style.css index e511731..638fb94 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -126,6 +126,7 @@ td { white-space: nowrap; } tr:hover td { background: rgba(88, 166, 255, 0.05); } +.trade-row { cursor: pointer; } .loading { text-align: center; color: var(--text-dim); padding: 20px !important; } .text-green { color: var(--green); }