修复显示bug
This commit is contained in:
@@ -433,9 +433,9 @@
|
|||||||
data-monitor-id="{{ o.id }}"
|
data-monitor-id="{{ o.id }}"
|
||||||
data-symbol="{{ o.symbol }}"
|
data-symbol="{{ o.symbol }}"
|
||||||
data-direction="{{ o.direction }}"
|
data-direction="{{ o.direction }}"
|
||||||
data-plan-sl="{{ o.stop_loss or '' }}"
|
data-plan-sl="{% if o.stop_loss %}{{ price_fmt(o.symbol, o.stop_loss) }}{% endif %}"
|
||||||
data-plan-tp="{{ o.take_profit or '' }}"
|
data-plan-tp="{% if o.take_profit %}{{ price_fmt(o.symbol, o.take_profit) }}{% endif %}"
|
||||||
data-entry="{{ o.trigger_price or '' }}">
|
data-entry="{% if o.trigger_price %}{{ price_fmt(o.symbol, o.trigger_price) }}{% endif %}">
|
||||||
<div class="pos-card-head">
|
<div class="pos-card-head">
|
||||||
<div class="pos-card-symbol">
|
<div class="pos-card-symbol">
|
||||||
<strong>{{ o.exchange_symbol or o.symbol }}</strong>
|
<strong>{{ o.exchange_symbol or o.symbol }}</strong>
|
||||||
@@ -924,9 +924,9 @@ function editTradeRecordReview(t){
|
|||||||
if(opened === null) return;
|
if(opened === null) return;
|
||||||
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
|
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
|
||||||
if(closed === null) return;
|
if(closed === null) return;
|
||||||
const stopLoss = prompt("止损价格(核对后用于统计)", String(t.stop_loss ?? ""));
|
const stopLoss = prompt("止损价格(核对后用于统计)", formatPriceForInput(t.stop_loss));
|
||||||
if(stopLoss === null) return;
|
if(stopLoss === null) return;
|
||||||
const takeProfit = prompt("止盈价格(核对后用于统计)", String(t.take_profit ?? ""));
|
const takeProfit = prompt("止盈价格(核对后用于统计)", formatPriceForInput(t.take_profit));
|
||||||
if(takeProfit === null) return;
|
if(takeProfit === null) return;
|
||||||
const pnl = prompt("最终盈亏(可手工核对后填写)", String(t.pnl_amount ?? ""));
|
const pnl = prompt("最终盈亏(可手工核对后填写)", String(t.pnl_amount ?? ""));
|
||||||
if(pnl === null) return;
|
if(pnl === null) return;
|
||||||
@@ -1174,6 +1174,24 @@ function coinFromSymbol(symbol){
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 输入框/备注用价格:去掉浮点尾数,按量级保留有效小数(与后端 price_fmt 兜底一致) */
|
||||||
|
function formatPriceForInput(val){
|
||||||
|
if(val === null || val === undefined || val === "") return "";
|
||||||
|
const v = Number(val);
|
||||||
|
if(!Number.isFinite(v)) return String(val);
|
||||||
|
const av = Math.abs(v);
|
||||||
|
let d;
|
||||||
|
if(av >= 10000) d = 2;
|
||||||
|
else if(av >= 100) d = 3;
|
||||||
|
else if(av >= 1) d = 4;
|
||||||
|
else if(av >= 0.01) d = 6;
|
||||||
|
else if(av >= 0.0001) d = 8;
|
||||||
|
else d = 10;
|
||||||
|
let text = v.toFixed(d);
|
||||||
|
if(text.includes(".")) text = text.replace(/\.?0+$/, "");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
function calcExpectedRrFromTrade(t){
|
function calcExpectedRrFromTrade(t){
|
||||||
const entry = Number(t.trigger_price);
|
const entry = Number(t.trigger_price);
|
||||||
const sl = Number(t.stop_loss);
|
const sl = Number(t.stop_loss);
|
||||||
@@ -1212,10 +1230,13 @@ function fillJournalFromTrade(t){
|
|||||||
setJournalField("real_rr", realRr);
|
setJournalField("real_rr", realRr);
|
||||||
const riskHint = document.getElementById("risk-amount-hint");
|
const riskHint = document.getElementById("risk-amount-hint");
|
||||||
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? String(riskAmount) : ""; }
|
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? String(riskAmount) : ""; }
|
||||||
|
const entryPx = formatPriceForInput(t.trigger_price);
|
||||||
|
const slPx = formatPriceForInput(t.stop_loss);
|
||||||
|
const tpPx = formatPriceForInput(t.take_profit);
|
||||||
const entryHint = document.getElementById("entry-price-hint");
|
const entryHint = document.getElementById("entry-price-hint");
|
||||||
if(entryHint){ entryHint.value = t.trigger_price || ""; }
|
if(entryHint){ entryHint.value = entryPx; }
|
||||||
const stopHint = document.getElementById("stop-loss-hint");
|
const stopHint = document.getElementById("stop-loss-hint");
|
||||||
if(stopHint){ stopHint.value = t.stop_loss || ""; }
|
if(stopHint){ stopHint.value = slPx; }
|
||||||
const dirHint = document.getElementById("direction-hint");
|
const dirHint = document.getElementById("direction-hint");
|
||||||
if(dirHint){ dirHint.value = t.direction || "long"; }
|
if(dirHint){ dirHint.value = t.direction || "long"; }
|
||||||
setJournalField("early_exit_trigger", "");
|
setJournalField("early_exit_trigger", "");
|
||||||
@@ -1232,7 +1253,7 @@ function fillJournalFromTrade(t){
|
|||||||
const er = String(t.result || "").trim();
|
const er = String(t.result || "").trim();
|
||||||
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
||||||
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
||||||
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${t.trigger_price || "-"} 止损:${t.stop_loss || "-"} 止盈:${t.take_profit || "-"} | 类型:${t.monitor_type || "-"}`;
|
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 类型:${t.monitor_type || "-"}`;
|
||||||
setJournalField("note", note);
|
setJournalField("note", note);
|
||||||
const form = document.getElementById("journal-form");
|
const form = document.getElementById("journal-form");
|
||||||
if(form && typeof form.scrollIntoView === "function"){
|
if(form && typeof form.scrollIntoView === "function"){
|
||||||
@@ -1492,8 +1513,8 @@ function openTpslEntrustModal(orderId){
|
|||||||
tpslEntrustMonitorId = orderId;
|
tpslEntrustMonitorId = orderId;
|
||||||
const slEl = document.getElementById('tpsl-modal-sl');
|
const slEl = document.getElementById('tpsl-modal-sl');
|
||||||
const tpEl = document.getElementById('tpsl-modal-tp');
|
const tpEl = document.getElementById('tpsl-modal-tp');
|
||||||
if(slEl) slEl.value = card.getAttribute('data-plan-sl') || '';
|
if(slEl) slEl.value = formatPriceForInput(card.getAttribute('data-plan-sl') || '');
|
||||||
if(tpEl) tpEl.value = card.getAttribute('data-plan-tp') || '';
|
if(tpEl) tpEl.value = formatPriceForInput(card.getAttribute('data-plan-tp') || '');
|
||||||
const modeEl = document.getElementById('tpsl-modal-mode');
|
const modeEl = document.getElementById('tpsl-modal-mode');
|
||||||
if(modeEl) modeEl.value = 'price';
|
if(modeEl) modeEl.value = 'price';
|
||||||
toggleTpslModalMode();
|
toggleTpslModalMode();
|
||||||
|
|||||||
@@ -433,9 +433,9 @@
|
|||||||
data-monitor-id="{{ o.id }}"
|
data-monitor-id="{{ o.id }}"
|
||||||
data-symbol="{{ o.symbol }}"
|
data-symbol="{{ o.symbol }}"
|
||||||
data-direction="{{ o.direction }}"
|
data-direction="{{ o.direction }}"
|
||||||
data-plan-sl="{{ o.stop_loss or '' }}"
|
data-plan-sl="{% if o.stop_loss %}{{ price_fmt(o.symbol, o.stop_loss) }}{% endif %}"
|
||||||
data-plan-tp="{{ o.take_profit or '' }}"
|
data-plan-tp="{% if o.take_profit %}{{ price_fmt(o.symbol, o.take_profit) }}{% endif %}"
|
||||||
data-entry="{{ o.trigger_price or '' }}">
|
data-entry="{% if o.trigger_price %}{{ price_fmt(o.symbol, o.trigger_price) }}{% endif %}">
|
||||||
<div class="pos-card-head">
|
<div class="pos-card-head">
|
||||||
<div class="pos-card-symbol">
|
<div class="pos-card-symbol">
|
||||||
<strong>{{ o.exchange_symbol or o.symbol }}</strong>
|
<strong>{{ o.exchange_symbol or o.symbol }}</strong>
|
||||||
@@ -934,9 +934,9 @@ function editTradeRecordReview(t){
|
|||||||
if(opened === null) return;
|
if(opened === null) return;
|
||||||
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
|
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
|
||||||
if(closed === null) return;
|
if(closed === null) return;
|
||||||
const stopLoss = prompt("止损价格(核对后用于统计)", String(t.stop_loss ?? ""));
|
const stopLoss = prompt("止损价格(核对后用于统计)", formatPriceForInput(t.stop_loss));
|
||||||
if(stopLoss === null) return;
|
if(stopLoss === null) return;
|
||||||
const takeProfit = prompt("止盈价格(核对后用于统计)", String(t.take_profit ?? ""));
|
const takeProfit = prompt("止盈价格(核对后用于统计)", formatPriceForInput(t.take_profit));
|
||||||
if(takeProfit === null) return;
|
if(takeProfit === null) return;
|
||||||
const pnl = prompt("最终盈亏(可手工核对后填写)", (t.pnl_amount === null || typeof t.pnl_amount === "undefined") ? "" : (Number.isFinite(Number(t.pnl_amount)) ? Number(t.pnl_amount).toFixed(2) : String(t.pnl_amount)));
|
const pnl = prompt("最终盈亏(可手工核对后填写)", (t.pnl_amount === null || typeof t.pnl_amount === "undefined") ? "" : (Number.isFinite(Number(t.pnl_amount)) ? Number(t.pnl_amount).toFixed(2) : String(t.pnl_amount)));
|
||||||
if(pnl === null) return;
|
if(pnl === null) return;
|
||||||
@@ -1184,6 +1184,24 @@ function coinFromSymbol(symbol){
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 输入框/备注用价格:去掉浮点尾数,按量级保留有效小数(与后端 price_fmt 兜底一致) */
|
||||||
|
function formatPriceForInput(val){
|
||||||
|
if(val === null || val === undefined || val === "") return "";
|
||||||
|
const v = Number(val);
|
||||||
|
if(!Number.isFinite(v)) return String(val);
|
||||||
|
const av = Math.abs(v);
|
||||||
|
let d;
|
||||||
|
if(av >= 10000) d = 2;
|
||||||
|
else if(av >= 100) d = 3;
|
||||||
|
else if(av >= 1) d = 4;
|
||||||
|
else if(av >= 0.01) d = 6;
|
||||||
|
else if(av >= 0.0001) d = 8;
|
||||||
|
else d = 10;
|
||||||
|
let text = v.toFixed(d);
|
||||||
|
if(text.includes(".")) text = text.replace(/\.?0+$/, "");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
function calcExpectedRrFromTrade(t){
|
function calcExpectedRrFromTrade(t){
|
||||||
const entry = Number(t.trigger_price);
|
const entry = Number(t.trigger_price);
|
||||||
const sl = Number(t.stop_loss);
|
const sl = Number(t.stop_loss);
|
||||||
@@ -1222,10 +1240,13 @@ function fillJournalFromTrade(t){
|
|||||||
setJournalField("real_rr", realRr);
|
setJournalField("real_rr", realRr);
|
||||||
const riskHint = document.getElementById("risk-amount-hint");
|
const riskHint = document.getElementById("risk-amount-hint");
|
||||||
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? riskAmount.toFixed(2) : ""; }
|
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? riskAmount.toFixed(2) : ""; }
|
||||||
|
const entryPx = formatPriceForInput(t.trigger_price);
|
||||||
|
const slPx = formatPriceForInput(t.stop_loss);
|
||||||
|
const tpPx = formatPriceForInput(t.take_profit);
|
||||||
const entryHint = document.getElementById("entry-price-hint");
|
const entryHint = document.getElementById("entry-price-hint");
|
||||||
if(entryHint){ entryHint.value = t.trigger_price || ""; }
|
if(entryHint){ entryHint.value = entryPx; }
|
||||||
const stopHint = document.getElementById("stop-loss-hint");
|
const stopHint = document.getElementById("stop-loss-hint");
|
||||||
if(stopHint){ stopHint.value = t.stop_loss || ""; }
|
if(stopHint){ stopHint.value = slPx; }
|
||||||
const dirHint = document.getElementById("direction-hint");
|
const dirHint = document.getElementById("direction-hint");
|
||||||
if(dirHint){ dirHint.value = t.direction || "long"; }
|
if(dirHint){ dirHint.value = t.direction || "long"; }
|
||||||
setJournalField("early_exit_trigger", "");
|
setJournalField("early_exit_trigger", "");
|
||||||
@@ -1242,7 +1263,7 @@ function fillJournalFromTrade(t){
|
|||||||
const er = String(t.result || "").trim();
|
const er = String(t.result || "").trim();
|
||||||
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
||||||
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
||||||
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${t.trigger_price || "-"} 止损:${t.stop_loss || "-"} 止盈:${t.take_profit || "-"} | 类型:${t.monitor_type || "-"}`;
|
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 类型:${t.monitor_type || "-"}`;
|
||||||
setJournalField("note", note);
|
setJournalField("note", note);
|
||||||
const form = document.getElementById("journal-form");
|
const form = document.getElementById("journal-form");
|
||||||
if(form && typeof form.scrollIntoView === "function"){
|
if(form && typeof form.scrollIntoView === "function"){
|
||||||
@@ -1502,8 +1523,8 @@ function openTpslEntrustModal(orderId){
|
|||||||
tpslEntrustMonitorId = orderId;
|
tpslEntrustMonitorId = orderId;
|
||||||
const slEl = document.getElementById('tpsl-modal-sl');
|
const slEl = document.getElementById('tpsl-modal-sl');
|
||||||
const tpEl = document.getElementById('tpsl-modal-tp');
|
const tpEl = document.getElementById('tpsl-modal-tp');
|
||||||
if(slEl) slEl.value = card.getAttribute('data-plan-sl') || '';
|
if(slEl) slEl.value = formatPriceForInput(card.getAttribute('data-plan-sl') || '');
|
||||||
if(tpEl) tpEl.value = card.getAttribute('data-plan-tp') || '';
|
if(tpEl) tpEl.value = formatPriceForInput(card.getAttribute('data-plan-tp') || '');
|
||||||
const modeEl = document.getElementById('tpsl-modal-mode');
|
const modeEl = document.getElementById('tpsl-modal-mode');
|
||||||
if(modeEl) modeEl.value = 'price';
|
if(modeEl) modeEl.value = 'price';
|
||||||
toggleTpslModalMode();
|
toggleTpslModalMode();
|
||||||
|
|||||||
@@ -981,9 +981,9 @@ function editTradeRecordReview(t){
|
|||||||
if(opened === null) return;
|
if(opened === null) return;
|
||||||
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
|
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
|
||||||
if(closed === null) return;
|
if(closed === null) return;
|
||||||
const stopLoss = prompt("止损价格(核对后用于统计)", String(t.stop_loss ?? ""));
|
const stopLoss = prompt("止损价格(核对后用于统计)", formatPriceForInput(t.stop_loss));
|
||||||
if(stopLoss === null) return;
|
if(stopLoss === null) return;
|
||||||
const takeProfit = prompt("止盈价格(核对后用于统计)", String(t.take_profit ?? ""));
|
const takeProfit = prompt("止盈价格(核对后用于统计)", formatPriceForInput(t.take_profit));
|
||||||
if(takeProfit === null) return;
|
if(takeProfit === null) return;
|
||||||
const pnl = prompt("最终盈亏(可手工核对后填写)", String(t.pnl_amount ?? ""));
|
const pnl = prompt("最终盈亏(可手工核对后填写)", String(t.pnl_amount ?? ""));
|
||||||
if(pnl === null) return;
|
if(pnl === null) return;
|
||||||
@@ -1184,6 +1184,24 @@ function coinFromSymbol(symbol){
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 输入框/备注用价格:去掉浮点尾数,按量级保留有效小数(与后端 price_fmt 兜底一致) */
|
||||||
|
function formatPriceForInput(val){
|
||||||
|
if(val === null || val === undefined || val === "") return "";
|
||||||
|
const v = Number(val);
|
||||||
|
if(!Number.isFinite(v)) return String(val);
|
||||||
|
const av = Math.abs(v);
|
||||||
|
let d;
|
||||||
|
if(av >= 10000) d = 2;
|
||||||
|
else if(av >= 100) d = 3;
|
||||||
|
else if(av >= 1) d = 4;
|
||||||
|
else if(av >= 0.01) d = 6;
|
||||||
|
else if(av >= 0.0001) d = 8;
|
||||||
|
else d = 10;
|
||||||
|
let text = v.toFixed(d);
|
||||||
|
if(text.includes(".")) text = text.replace(/\.?0+$/, "");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
function calcExpectedRrFromTrade(t){
|
function calcExpectedRrFromTrade(t){
|
||||||
const entry = Number(t.trigger_price);
|
const entry = Number(t.trigger_price);
|
||||||
const sl = Number(t.stop_loss);
|
const sl = Number(t.stop_loss);
|
||||||
@@ -1222,10 +1240,13 @@ function fillJournalFromTrade(t){
|
|||||||
setJournalField("real_rr", realRr);
|
setJournalField("real_rr", realRr);
|
||||||
const riskHint = document.getElementById("risk-amount-hint");
|
const riskHint = document.getElementById("risk-amount-hint");
|
||||||
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? String(riskAmount) : ""; }
|
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? String(riskAmount) : ""; }
|
||||||
|
const entryPx = formatPriceForInput(t.trigger_price);
|
||||||
|
const slPx = formatPriceForInput(t.stop_loss);
|
||||||
|
const tpPx = formatPriceForInput(t.take_profit);
|
||||||
const entryHint = document.getElementById("entry-price-hint");
|
const entryHint = document.getElementById("entry-price-hint");
|
||||||
if(entryHint){ entryHint.value = t.trigger_price || ""; }
|
if(entryHint){ entryHint.value = entryPx; }
|
||||||
const stopHint = document.getElementById("stop-loss-hint");
|
const stopHint = document.getElementById("stop-loss-hint");
|
||||||
if(stopHint){ stopHint.value = t.stop_loss || ""; }
|
if(stopHint){ stopHint.value = slPx; }
|
||||||
const dirHint = document.getElementById("direction-hint");
|
const dirHint = document.getElementById("direction-hint");
|
||||||
if(dirHint){ dirHint.value = t.direction || "long"; }
|
if(dirHint){ dirHint.value = t.direction || "long"; }
|
||||||
setJournalField("early_exit_trigger", "");
|
setJournalField("early_exit_trigger", "");
|
||||||
@@ -1240,7 +1261,7 @@ function fillJournalFromTrade(t){
|
|||||||
const er = String(t.result || "").trim();
|
const er = String(t.result || "").trim();
|
||||||
const exitTrigMap = { 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
const exitTrigMap = { 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
||||||
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
||||||
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${t.trigger_price || "-"} 止损:${t.stop_loss || "-"} 止盈:${t.take_profit || "-"} | 类型:${t.monitor_type || "-"}`;
|
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 类型:${t.monitor_type || "-"}`;
|
||||||
setJournalField("note", note);
|
setJournalField("note", note);
|
||||||
const form = document.getElementById("journal-form");
|
const form = document.getElementById("journal-form");
|
||||||
if(form && typeof form.scrollIntoView === "function"){
|
if(form && typeof form.scrollIntoView === "function"){
|
||||||
|
|||||||
@@ -798,9 +798,9 @@ function editTradeRecordReview(t){
|
|||||||
if(opened === null) return;
|
if(opened === null) return;
|
||||||
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
|
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
|
||||||
if(closed === null) return;
|
if(closed === null) return;
|
||||||
const stopLoss = prompt("止损价格(核对后用于统计)", String(t.stop_loss ?? ""));
|
const stopLoss = prompt("止损价格(核对后用于统计)", formatPriceForInput(t.stop_loss));
|
||||||
if(stopLoss === null) return;
|
if(stopLoss === null) return;
|
||||||
const takeProfit = prompt("止盈价格(核对后用于统计)", String(t.take_profit ?? ""));
|
const takeProfit = prompt("止盈价格(核对后用于统计)", formatPriceForInput(t.take_profit));
|
||||||
if(takeProfit === null) return;
|
if(takeProfit === null) return;
|
||||||
const pnl = prompt("最终盈亏(可手工核对后填写)", String(t.pnl_amount ?? ""));
|
const pnl = prompt("最终盈亏(可手工核对后填写)", String(t.pnl_amount ?? ""));
|
||||||
if(pnl === null) return;
|
if(pnl === null) return;
|
||||||
@@ -1007,6 +1007,24 @@ function coinFromSymbol(symbol){
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 输入框/备注用价格:去掉浮点尾数,按量级保留有效小数(与后端 price_fmt 兜底一致) */
|
||||||
|
function formatPriceForInput(val){
|
||||||
|
if(val === null || val === undefined || val === "") return "";
|
||||||
|
const v = Number(val);
|
||||||
|
if(!Number.isFinite(v)) return String(val);
|
||||||
|
const av = Math.abs(v);
|
||||||
|
let d;
|
||||||
|
if(av >= 10000) d = 2;
|
||||||
|
else if(av >= 100) d = 3;
|
||||||
|
else if(av >= 1) d = 4;
|
||||||
|
else if(av >= 0.01) d = 6;
|
||||||
|
else if(av >= 0.0001) d = 8;
|
||||||
|
else d = 10;
|
||||||
|
let text = v.toFixed(d);
|
||||||
|
if(text.includes(".")) text = text.replace(/\.?0+$/, "");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
function calcExpectedRrFromTrade(t){
|
function calcExpectedRrFromTrade(t){
|
||||||
const entry = Number(t.trigger_price);
|
const entry = Number(t.trigger_price);
|
||||||
const sl = Number(t.stop_loss);
|
const sl = Number(t.stop_loss);
|
||||||
@@ -1045,10 +1063,13 @@ function fillJournalFromTrade(t){
|
|||||||
setJournalField("real_rr", realRr);
|
setJournalField("real_rr", realRr);
|
||||||
const riskHint = document.getElementById("risk-amount-hint");
|
const riskHint = document.getElementById("risk-amount-hint");
|
||||||
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? String(riskAmount) : ""; }
|
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? String(riskAmount) : ""; }
|
||||||
|
const entryPx = formatPriceForInput(t.trigger_price);
|
||||||
|
const slPx = formatPriceForInput(t.stop_loss);
|
||||||
|
const tpPx = formatPriceForInput(t.take_profit);
|
||||||
const entryHint = document.getElementById("entry-price-hint");
|
const entryHint = document.getElementById("entry-price-hint");
|
||||||
if(entryHint){ entryHint.value = t.trigger_price || ""; }
|
if(entryHint){ entryHint.value = entryPx; }
|
||||||
const stopHint = document.getElementById("stop-loss-hint");
|
const stopHint = document.getElementById("stop-loss-hint");
|
||||||
if(stopHint){ stopHint.value = t.stop_loss || ""; }
|
if(stopHint){ stopHint.value = slPx; }
|
||||||
const dirHint = document.getElementById("direction-hint");
|
const dirHint = document.getElementById("direction-hint");
|
||||||
if(dirHint){ dirHint.value = t.direction || "long"; }
|
if(dirHint){ dirHint.value = t.direction || "long"; }
|
||||||
setJournalField("early_exit_trigger", "");
|
setJournalField("early_exit_trigger", "");
|
||||||
@@ -1065,7 +1086,7 @@ function fillJournalFromTrade(t){
|
|||||||
const er = String(t.result || "").trim();
|
const er = String(t.result || "").trim();
|
||||||
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
||||||
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
||||||
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${t.trigger_price || "-"} 止损:${t.stop_loss || "-"} 止盈:${t.take_profit || "-"} | 类型:${t.monitor_type || "-"}`;
|
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 类型:${t.monitor_type || "-"}`;
|
||||||
setJournalField("note", note);
|
setJournalField("note", note);
|
||||||
const form = document.getElementById("journal-form");
|
const form = document.getElementById("journal-form");
|
||||||
if(form && typeof form.scrollIntoView === "function"){
|
if(form && typeof form.scrollIntoView === "function"){
|
||||||
|
|||||||
Reference in New Issue
Block a user