fix: sync live TP/SL to position cards after entrust changes

Use exchange TP/SL for display and DB sync on price_snapshot polls, refresh instance UI cells on each tick, and merge live values into hub monitor board.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-09 11:06:27 +08:00
parent 7cb55f6557
commit f7d94f67d7
12 changed files with 291 additions and 89 deletions
+8 -6
View File
@@ -1723,14 +1723,16 @@ function paintPlanTpslDisplay(orderId, snap){
const slEl = document.getElementById(`order-plan-sl-${orderId}`);
const tpEl = document.getElementById(`order-plan-tp-${orderId}`);
const rrEl = document.getElementById(`order-rr-${orderId}`);
const slDisp = snap.stop_loss_display;
const tpDisp = snap.take_profit_display;
if(slEl && slDisp) slEl.innerText = slDisp;
if(tpEl && tpDisp) tpEl.innerText = tpDisp;
const slRaw = snap.stop_loss_raw != null && snap.stop_loss_raw !== "" ? snap.stop_loss_raw : snap.stop_loss;
const tpRaw = snap.take_profit_raw != null && snap.take_profit_raw !== "" ? snap.take_profit_raw : snap.take_profit;
const slDisp = snap.stop_loss_display || (slRaw != null && slRaw !== "" ? formatPriceForInput(slRaw) : null);
const tpDisp = snap.take_profit_display || (tpRaw != null && tpRaw !== "" ? formatPriceForInput(tpRaw) : null);
if(slEl) slEl.innerText = slDisp || "—";
if(tpEl) tpEl.innerText = tpDisp || "—";
if(card){
if(snap.stop_loss_raw != null && snap.stop_loss_raw !== "") card.setAttribute('data-plan-sl', formatPriceForInput(snap.stop_loss_raw));
if(slRaw != null && slRaw !== "") card.setAttribute('data-plan-sl', formatPriceForInput(slRaw));
else if(slDisp) card.setAttribute('data-plan-sl', slDisp);
if(snap.take_profit_raw != null && snap.take_profit_raw !== "") card.setAttribute('data-plan-tp', formatPriceForInput(snap.take_profit_raw));
if(tpRaw != null && tpRaw !== "") card.setAttribute('data-plan-tp', formatPriceForInput(tpRaw));
else if(tpDisp) card.setAttribute('data-plan-tp', tpDisp);
}
if(rrEl && typeof snap.rr_ratio !== "undefined") rrEl.innerText = formatRrRatio(snap.rr_ratio);