修复gate盈亏比

This commit is contained in:
dekun
2026-05-25 11:07:47 +08:00
parent 5f4f33cc10
commit dccd490a46
4 changed files with 40 additions and 11 deletions
+7 -5
View File
@@ -1865,17 +1865,19 @@ if(addOrderForm){
}
const sl = Number((document.getElementById("order-sl")||{}).value);
const tp = Number((document.getElementById("order-tp")||{}).value);
let entry = sl;
if(!symbol){
if(rejectManualOrderRr(calcClientRr(direction, entry, sl, tp))) return;
allowManualOrderSubmit(addOrderForm);
alert("请先填写币种,以便按市价校验盈亏比");
return;
}
fetch(`/api/order_defaults?symbol=${encodeURIComponent(symbol)}&direction=${encodeURIComponent(direction)}`)
.then(r=>r.json())
.then(data=>{
const px = data.last_price || data.price;
if(px) entry = Number(px);
const px = data.last_price ?? data.price;
const entry = Number(px);
if(!Number.isFinite(entry) || entry <= 0){
alert("无法获取市价,请稍后重试");
return;
}
if(rejectManualOrderRr(calcClientRr(direction, entry, sl, tp))) return;
allowManualOrderSubmit(addOrderForm);
})
@@ -143,7 +143,8 @@ function paintOrder(order){
document.getElementById("m-entry").innerText = fmt(order.trigger_price, 8);
document.getElementById("m-sl").innerText = fmt(order.stop_loss, 8);
document.getElementById("m-tp").innerText = fmt(order.take_profit, 8);
document.getElementById("m-rr").innerText = (order.rr_ratio === null || typeof order.rr_ratio === "undefined") ? "-" : `1:${Number(order.rr_ratio).toFixed(2)}`;
const rr = order.rr_ratio;
document.getElementById("m-rr").innerText = (rr === null || typeof rr === "undefined") ? "-:1" : `${Number(rr).toFixed(2)}:1`;
document.getElementById("m-price").innerText = fmt(order.current_price, 8);
const pnlEl = document.getElementById("m-pnl");
pnlEl.innerText = `${fmt(order.float_pnl, 4)}U (${fmt(order.float_pct, 2)}%)`;
@@ -143,7 +143,8 @@ function paintOrder(order){
document.getElementById("m-entry").innerText = fmt(order.trigger_price, 8);
document.getElementById("m-sl").innerText = fmt(order.stop_loss, 8);
document.getElementById("m-tp").innerText = fmt(order.take_profit, 8);
document.getElementById("m-rr").innerText = (order.rr_ratio === null || typeof order.rr_ratio === "undefined") ? "-" : `1:${Number(order.rr_ratio).toFixed(2)}`;
const rr = order.rr_ratio;
document.getElementById("m-rr").innerText = (rr === null || typeof rr === "undefined") ? "-:1" : `${Number(rr).toFixed(2)}:1`;
document.getElementById("m-price").innerText = fmt(order.current_price, 8);
const pnlEl = document.getElementById("m-pnl");
pnlEl.innerText = `${fmt(order.float_pnl, 4)}U (${fmt(order.float_pct, 2)}%)`;