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:
@@ -323,6 +323,10 @@ func (d *Dashboard) broadcastLoop() {
|
|||||||
netPnl := longPnl + shortPnl - totalFees
|
netPnl := longPnl + shortPnl - totalFees
|
||||||
|
|
||||||
currentSpread := (hlP - bgP) / bgP * 100
|
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["current_spread"] = math.Round(currentSpread*10000) / 10000
|
||||||
posEntry["pnl_est"] = math.Round(netPnl*10000) / 10000
|
posEntry["pnl_est"] = math.Round(netPnl*10000) / 10000
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -603,6 +603,10 @@ document.addEventListener('keydown', function(e) {
|
|||||||
if (e.key === 'Escape') closeTradeDetail();
|
if (e.key === 'Escape') closeTradeDetail();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Expose modal functions to global scope for HTML onclick handlers
|
||||||
|
window.openTradeDetail = openTradeDetail;
|
||||||
|
window.closeTradeDetail = closeTradeDetail;
|
||||||
|
|
||||||
// ---- Init ----
|
// ---- Init ----
|
||||||
function init() {
|
function init() {
|
||||||
connectSSE();
|
connectSSE();
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ td {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
tr:hover td { background: rgba(88, 166, 255, 0.05); }
|
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; }
|
.loading { text-align: center; color: var(--text-dim); padding: 20px !important; }
|
||||||
|
|
||||||
.text-green { color: var(--green); }
|
.text-green { color: var(--green); }
|
||||||
|
|||||||
Reference in New Issue
Block a user