fix(dashboard): current spread sign for HL→BG positions

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.
This commit is contained in:
jackyu66git
2026-05-03 19:11:34 +08:00
parent 505137bcb0
commit 57344d33f7
3 changed files with 9 additions and 0 deletions
+4
View File
@@ -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
}