feat: add force-close exit trigger and round journal real RR to 2dp

复盘离场触发增加强制清仓;填入复盘与自动计算实际盈亏比保留两位小数。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-07 00:40:55 +08:00
parent 1092816359
commit 5a0d18cf99
6 changed files with 16 additions and 12 deletions
+3 -2
View File
@@ -1112,6 +1112,7 @@ EARLY_EXIT_TRIGGERS = (
"保本止盈",
"移动止盈",
TIME_CLOSE_RESULT,
"强制清仓",
"手动平仓",
"止损",
"其他",
@@ -2593,7 +2594,7 @@ def calc_actual_rr(pnl_amount, risk_amount):
r = float(risk_amount or 0)
if r <= 0:
return None
return round(float(pnl_amount or 0) / r, 4)
return round(float(pnl_amount or 0) / r, 2)
except Exception:
return None
@@ -9210,7 +9211,7 @@ def add_journal():
pnl_hint = float(d.get("pnl") or 0)
# 口径统一:实际RR = 实际盈亏 / 以损定仓对应的初始风险金额
if risk_amount_hint > 0:
real_rr_text = f"{(pnl_hint / risk_amount_hint):.4f}"
real_rr_text = f"{(pnl_hint / risk_amount_hint):.2f}"
except Exception:
pass
+3 -2
View File
@@ -1099,6 +1099,7 @@ EARLY_EXIT_TRIGGERS = (
"保本止盈",
"移动止盈",
TIME_CLOSE_RESULT,
"强制清仓",
"手动平仓",
"止损",
"其他",
@@ -2310,7 +2311,7 @@ def calc_actual_rr(pnl_amount, risk_amount):
r = float(risk_amount or 0)
if r <= 0:
return None
return round(float(pnl_amount or 0) / r, 4)
return round(float(pnl_amount or 0) / r, 2)
except Exception:
return None
@@ -9073,7 +9074,7 @@ def add_journal():
pnl_hint = float(d.get("pnl") or 0)
# 口径统一:实际RR = 实际盈亏 / 以损定仓对应的初始风险金额
if risk_amount_hint > 0:
real_rr_text = f"{(pnl_hint / risk_amount_hint):.4f}"
real_rr_text = f"{(pnl_hint / risk_amount_hint):.2f}"
except Exception:
pass
+3 -2
View File
@@ -1102,6 +1102,7 @@ EARLY_EXIT_TRIGGERS = (
"保本止盈",
"移动止盈",
TIME_CLOSE_RESULT,
"强制清仓",
"手动平仓",
"止损",
"其他",
@@ -2204,7 +2205,7 @@ def calc_actual_rr(pnl_amount, risk_amount):
r = float(risk_amount or 0)
if r <= 0:
return None
return round(float(pnl_amount or 0) / r, 4)
return round(float(pnl_amount or 0) / r, 2)
except Exception:
return None
@@ -8593,7 +8594,7 @@ def add_journal():
pnl_hint = float(d.get("pnl") or 0)
# 口径统一:实际RR = 实际盈亏 / 以损定仓对应的初始风险金额
if risk_amount_hint > 0:
real_rr_text = f"{(pnl_hint / risk_amount_hint):.4f}"
real_rr_text = f"{(pnl_hint / risk_amount_hint):.2f}"
except Exception:
pass
@@ -417,7 +417,7 @@ function setJournalField(name, value){
el.value = String(value);
}
const EARLY_EXIT_TRIGGERS = new Set(["止盈","保本止盈","移动止盈","时间平仓","手动平仓","止损","其他"]);
const EARLY_EXIT_TRIGGERS = new Set(["止盈","保本止盈","移动止盈","时间平仓","强制清仓","手动平仓","止损","其他"]);
const KEY_ENTRY_REASON_BY_SIGNAL = {
"箱体突破": "关键位箱体突破",
"收敛突破": "关键位收敛突破",
@@ -552,7 +552,7 @@ function fillJournalFromTrade(t){
}
}
const er = String(t.result || "").trim();
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 时间平仓: "时间平仓", 手动平仓: "手动平仓", 止损: "止损" };
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 时间平仓: "时间平仓", 强制清仓: "强制清仓", 手动平仓: "手动平仓", 止损: "止损" };
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 类型:${t.monitor_type || "-"}`;
setJournalField("note", note);
@@ -575,7 +575,7 @@ function recomputeJournalRealRr(){
const pnl = Number(String(pnlEl.value || "").trim());
const risk = Number(String(riskHint.value || "").trim());
if(Number.isFinite(pnl) && Number.isFinite(risk) && risk > 0){
rrEl.value = (pnl / risk).toFixed(4);
rrEl.value = (pnl / risk).toFixed(2);
}
}
+3 -3
View File
@@ -981,7 +981,7 @@ function setJournalField(name, value){
el.value = String(value);
}
const EARLY_EXIT_TRIGGERS = new Set(["止盈","保本止盈","移动止盈","时间平仓","手动平仓","止损","其他"]);
const EARLY_EXIT_TRIGGERS = new Set(["止盈","保本止盈","移动止盈","时间平仓","强制清仓","手动平仓","止损","其他"]);
const KEY_ENTRY_REASON_BY_SIGNAL = {
"箱体突破": "关键位箱体突破",
"收敛突破": "关键位收敛突破",
@@ -1116,7 +1116,7 @@ function fillJournalFromTrade(t){
}
}
const er = String(t.result || "").trim();
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 时间平仓: "时间平仓", 手动平仓: "手动平仓", 止损: "止损" };
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 时间平仓: "时间平仓", 强制清仓: "强制清仓", 手动平仓: "手动平仓", 止损: "止损" };
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 类型:${t.monitor_type || "-"}`;
setJournalField("note", note);
@@ -1139,7 +1139,7 @@ function recomputeJournalRealRr(){
const pnl = Number(String(pnlEl.value || "").trim());
const risk = Number(String(riskHint.value || "").trim());
if(Number.isFinite(pnl) && Number.isFinite(risk) && risk > 0){
rrEl.value = (pnl / risk).toFixed(4);
rrEl.value = (pnl / risk).toFixed(2);
}
}
@@ -22,6 +22,7 @@
<option value="保本止盈">保本止盈</option>
<option value="移动止盈">移动止盈</option>
<option value="时间平仓">时间平仓</option>
<option value="强制清仓">强制清仓</option>
<option value="手动平仓">手动平仓</option>
<option value="止损">止损</option>
<option value="其他">其他</option>