Fix roll position display: live contracts, TP profit, and 2-decimal qty precision.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -788,6 +788,8 @@ function submitTpslEntrust(){
|
||||
if(data.exchange_tpsl) paintExchangeTpslRow(orderId, data.exchange_tpsl);
|
||||
paintPlanTpslDisplay(orderId, data);
|
||||
paintLatestRiskDisplay(orderId, data);
|
||||
paintContractsDisplay(orderId, data);
|
||||
paintTpProfitDisplay(orderId, data);
|
||||
const rrEl = document.getElementById(`order-rr-${orderId}`);
|
||||
if(rrEl){
|
||||
const rr = data.display_rr_ratio != null && data.display_rr_ratio !== "" ? data.display_rr_ratio : data.planned_rr;
|
||||
@@ -881,7 +883,20 @@ function paintContractsDisplay(orderId, snap){
|
||||
if(!el || !snap) return;
|
||||
const v = snap.contracts != null && snap.contracts !== "" ? snap.contracts : snap.order_amount;
|
||||
const n = v != null && v !== "" ? Number(v) : NaN;
|
||||
el.innerText = Number.isFinite(n) ? String(parseFloat(n.toFixed(4))) : "—";
|
||||
el.innerText = Number.isFinite(n) ? n.toFixed(2) : "—";
|
||||
}
|
||||
function paintTpProfitDisplay(orderId, snap){
|
||||
const el = document.getElementById(`order-tp-profit-${orderId}`);
|
||||
if(!el) return;
|
||||
const v = snap && snap.reward_at_tp_usdt;
|
||||
const n = v != null && v !== "" ? Number(v) : NaN;
|
||||
if(Number.isFinite(n)){
|
||||
el.innerText = `${n.toFixed(2)}U`;
|
||||
el.classList.add("pos-tp-profit");
|
||||
} else {
|
||||
el.innerText = "—";
|
||||
el.classList.remove("pos-tp-profit");
|
||||
}
|
||||
}
|
||||
|
||||
function paintPriceTrend(el, key, value){
|
||||
@@ -983,6 +998,7 @@ function refreshPriceSnapshot(){
|
||||
}
|
||||
paintLatestRiskDisplay(o.id, o);
|
||||
paintContractsDisplay(o.id, o);
|
||||
paintTpProfitDisplay(o.id, o);
|
||||
paintBreakevenBadge(o.id, o.sl_breakeven_secured);
|
||||
if(o.exchange_tpsl) paintExchangeTpslRow(o.id, o.exchange_tpsl);
|
||||
paintPlanTpslDisplay(o.id, o);
|
||||
@@ -1317,6 +1333,9 @@ function refreshPriceSnapshotConditional(){
|
||||
if(tradePage){
|
||||
(data.order_prices || []).forEach(o=>{
|
||||
paintOrderMarkAndPnl(o.id, o);
|
||||
paintLatestRiskDisplay(o.id, o);
|
||||
paintContractsDisplay(o.id, o);
|
||||
paintTpProfitDisplay(o.id, o);
|
||||
const exM = document.getElementById(`order-ex-margin-${o.id}`);
|
||||
if(exM){
|
||||
const mv = o.exchange_initial_margin;
|
||||
|
||||
@@ -139,7 +139,11 @@
|
||||
</div>
|
||||
<div class="pos-cell">
|
||||
<span class="pos-label">张数</span>
|
||||
<span class="pos-value" id="order-contracts-{{ o.id }}">{% if o.order_amount is not none %}{{ '%g'|format(o.order_amount) }}{% else %}—{% endif %}</span>
|
||||
<span class="pos-value" id="order-contracts-{{ o.id }}">{% if o.order_amount is not none %}{{ '%.2f'|format(o.order_amount) }}{% else %}—{% endif %}</span>
|
||||
</div>
|
||||
<div class="pos-cell">
|
||||
<span class="pos-label">盈利金额</span>
|
||||
<span class="pos-value pos-tp-profit" id="order-tp-profit-{{ o.id }}">—</span>
|
||||
</div>
|
||||
<div class="pos-cell">
|
||||
<span class="pos-label">标记价</span>
|
||||
|
||||
@@ -211,7 +211,11 @@
|
||||
</div>
|
||||
<div class="pos-cell">
|
||||
<span class="pos-label">张数</span>
|
||||
<span class="pos-value" id="order-contracts-{{ o.id }}">{% if o.order_amount is not none %}{{ '%g'|format(o.order_amount) }}{% else %}—{% endif %}</span>
|
||||
<span class="pos-value" id="order-contracts-{{ o.id }}">{% if o.order_amount is not none %}{{ '%.2f'|format(o.order_amount) }}{% else %}—{% endif %}</span>
|
||||
</div>
|
||||
<div class="pos-cell">
|
||||
<span class="pos-label">盈利金额</span>
|
||||
<span class="pos-value pos-tp-profit" id="order-tp-profit-{{ o.id }}">—</span>
|
||||
</div>
|
||||
<div class="pos-cell">
|
||||
<span class="pos-label">标记价</span>
|
||||
@@ -1304,6 +1308,8 @@ function submitTpslEntrust(){
|
||||
if(data.exchange_tpsl) paintExchangeTpslRow(orderId, data.exchange_tpsl);
|
||||
paintPlanTpslDisplay(orderId, data);
|
||||
paintLatestRiskDisplay(orderId, data);
|
||||
paintContractsDisplay(orderId, data);
|
||||
paintTpProfitDisplay(orderId, data);
|
||||
const rrEl = document.getElementById(`order-rr-${orderId}`);
|
||||
if(rrEl){
|
||||
const rr = data.display_rr_ratio != null && data.display_rr_ratio !== "" ? data.display_rr_ratio : data.planned_rr;
|
||||
@@ -1393,7 +1399,20 @@ function paintContractsDisplay(orderId, snap){
|
||||
if(!el || !snap) return;
|
||||
const v = snap.contracts != null && snap.contracts !== "" ? snap.contracts : snap.order_amount;
|
||||
const n = v != null && v !== "" ? Number(v) : NaN;
|
||||
el.innerText = Number.isFinite(n) ? String(parseFloat(n.toFixed(4))) : "—";
|
||||
el.innerText = Number.isFinite(n) ? n.toFixed(2) : "—";
|
||||
}
|
||||
function paintTpProfitDisplay(orderId, snap){
|
||||
const el = document.getElementById(`order-tp-profit-${orderId}`);
|
||||
if(!el) return;
|
||||
const v = snap && snap.reward_at_tp_usdt;
|
||||
const n = v != null && v !== "" ? Number(v) : NaN;
|
||||
if(Number.isFinite(n)){
|
||||
el.innerText = `${n.toFixed(2)}U`;
|
||||
el.classList.add("pos-tp-profit");
|
||||
} else {
|
||||
el.innerText = "—";
|
||||
el.classList.remove("pos-tp-profit");
|
||||
}
|
||||
}
|
||||
|
||||
function paintPriceTrend(el, key, value){
|
||||
@@ -1526,6 +1545,7 @@ function refreshPriceSnapshot(){
|
||||
}
|
||||
paintLatestRiskDisplay(o.id, o);
|
||||
paintContractsDisplay(o.id, o);
|
||||
paintTpProfitDisplay(o.id, o);
|
||||
paintBreakevenBadge(o.id, o.sl_breakeven_secured);
|
||||
if(o.exchange_tpsl) paintExchangeTpslRow(o.id, o.exchange_tpsl);
|
||||
paintPlanTpslDisplay(o.id, o);
|
||||
@@ -1916,6 +1936,9 @@ function refreshPriceSnapshotConditional(){
|
||||
}
|
||||
const rrEl = document.getElementById(`order-rr-${o.id}`);
|
||||
if(rrEl) rrEl.innerText = formatRrRatio(o.rr_ratio);
|
||||
paintLatestRiskDisplay(o.id, o);
|
||||
paintContractsDisplay(o.id, o);
|
||||
paintTpProfitDisplay(o.id, o);
|
||||
paintBreakevenBadge(o.id, o.sl_breakeven_secured);
|
||||
paintExchangeTpslRow(o.id, o.exchange_tpsl || {});
|
||||
paintPlanTpslDisplay(o.id, o);
|
||||
|
||||
Reference in New Issue
Block a user