Show hedge close reasons in Chinese on options review.
Map plan/leg close_reason codes like target_down_win_leg and expiry to Chinese labels in detail, form, and stats. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1402,6 +1402,11 @@
|
||||
target_win_leg: "期期平盈利腿",
|
||||
target_up_win_leg: "期期上破·平盈利腿",
|
||||
target_down_win_leg: "期期下破·平盈利腿",
|
||||
oo_rest_closing: "期期全平·清残腿中",
|
||||
oo_rest_closed: "期期全平·两腿已平",
|
||||
orphaned_after_tp: "止盈后持有至到期",
|
||||
orphaned_option_expiry: "残腿到期",
|
||||
hold_to_expiry: "持有至到期",
|
||||
expiry: "到期",
|
||||
manual: "人工结束",
|
||||
partial_fail: "半腿失败",
|
||||
|
||||
@@ -67,13 +67,51 @@
|
||||
return s;
|
||||
}
|
||||
|
||||
function closeReasonLabel(r) {
|
||||
var map = {
|
||||
perp_tp: "永续止盈",
|
||||
perp_sl: "永续止损",
|
||||
oo_expiry_loss: "期期到期亏损",
|
||||
oo_expiry_win: "期期到期盈利",
|
||||
target_win_leg: "期期平盈利腿",
|
||||
target_up_win_leg: "期期上破·平盈利腿",
|
||||
target_down_win_leg: "期期下破·平盈利腿",
|
||||
oo_rest_closing: "期期全平·清残腿中",
|
||||
oo_rest_closed: "期期全平·两腿已平",
|
||||
orphaned_after_tp: "止盈后持有至到期",
|
||||
orphaned_option_expiry: "残腿到期",
|
||||
hold_to_expiry: "持有至到期",
|
||||
expiry: "到期",
|
||||
manual: "人工结束",
|
||||
partial_fail: "半腿失败",
|
||||
cancelled: "已取消",
|
||||
tp: "止盈",
|
||||
sl: "止损",
|
||||
};
|
||||
var key = String(r || "").trim();
|
||||
if (!key) return "—";
|
||||
return map[key] || key;
|
||||
}
|
||||
|
||||
function legRoleLabel(role) {
|
||||
var map = {
|
||||
perp: "永续腿",
|
||||
option_hedge: "保险期权",
|
||||
option_a: "期期腿A",
|
||||
option_b: "期期腿B",
|
||||
};
|
||||
var key = String(role || "").trim();
|
||||
if (!key) return "—";
|
||||
return map[key] || key;
|
||||
}
|
||||
|
||||
function tradeTitle(t) {
|
||||
if (!t) return "—";
|
||||
if (t.source_type === "option_spot") return t.inst_id || "—";
|
||||
return (
|
||||
(t.underlying || "") +
|
||||
(t.direction ? " " + t.direction : "") +
|
||||
(t.plan_close_reason ? " · " + t.plan_close_reason : "")
|
||||
(t.plan_close_reason ? " · " + closeReasonLabel(t.plan_close_reason) : "")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -671,13 +709,13 @@
|
||||
.map(function (leg) {
|
||||
return (
|
||||
"<tr><td>" +
|
||||
escapeHtml(leg.leg_role || "") +
|
||||
escapeHtml(legRoleLabel(leg.leg_role)) +
|
||||
"</td><td>" +
|
||||
escapeHtml(leg.inst_id || leg.symbol || "") +
|
||||
"</td><td>" +
|
||||
fmtPnl(leg.realized_pnl) +
|
||||
"</td><td>" +
|
||||
escapeHtml(leg.close_reason || "") +
|
||||
escapeHtml(closeReasonLabel(leg.close_reason)) +
|
||||
"</td></tr>"
|
||||
);
|
||||
})
|
||||
@@ -699,10 +737,12 @@
|
||||
var lines = items
|
||||
.slice(0, 8)
|
||||
.map(function (g) {
|
||||
var keyLabel =
|
||||
title === "对冲结束原因" ? closeReasonLabel(g.key) : String(g.key || "");
|
||||
return (
|
||||
'<div class="or-stat-row">' +
|
||||
'<span class="or-stat-key">' +
|
||||
escapeHtml(g.key) +
|
||||
escapeHtml(keyLabel) +
|
||||
" · " +
|
||||
g.count +
|
||||
"笔</span>" +
|
||||
@@ -947,12 +987,13 @@
|
||||
($("or-f-inst") || {}).value =
|
||||
t.source_type === "option_spot"
|
||||
? t.inst_id || ""
|
||||
: (t.source_label || "") + (t.plan_close_reason ? " · " + t.plan_close_reason : "");
|
||||
: (t.source_label || "") +
|
||||
(t.plan_close_reason ? " · " + closeReasonLabel(t.plan_close_reason) : "");
|
||||
($("or-f-pnl") || {}).value = fmtPnl(t.realized_pnl_total);
|
||||
($("or-f-hold") || {}).value = fmtHold(t.hold_seconds);
|
||||
setSelectValue($("or-f-strategy"), e.strategy_tag || "");
|
||||
setSelectValue($("or-f-direction"), e.direction_view || autoDirection(t));
|
||||
($("or-f-exit") || {}).value = e.exit_reason || t.plan_close_reason || "";
|
||||
($("or-f-exit") || {}).value = e.exit_reason || closeReasonLabel(t.plan_close_reason) || "";
|
||||
($("or-f-followed") || {}).value = e.followed_plan || "";
|
||||
setSelectValue($("or-f-result"), e.result_tag || autoResultTag(t.realized_pnl_total));
|
||||
setSelectValue($("or-f-entry"), e.entry_logic || "");
|
||||
@@ -1008,13 +1049,13 @@
|
||||
.map(function (leg) {
|
||||
return (
|
||||
"<tr><td>" +
|
||||
escapeHtml(leg.leg_role || "") +
|
||||
escapeHtml(legRoleLabel(leg.leg_role)) +
|
||||
"</td><td>" +
|
||||
escapeHtml(leg.inst_id || leg.symbol || "") +
|
||||
"</td><td>" +
|
||||
fmtPnl(leg.realized_pnl) +
|
||||
"</td><td>" +
|
||||
escapeHtml(leg.close_reason || "") +
|
||||
escapeHtml(closeReasonLabel(leg.close_reason)) +
|
||||
"</td></tr>"
|
||||
);
|
||||
})
|
||||
|
||||
@@ -394,4 +394,4 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<script src="/static/options_review.js?v=18"></script>
|
||||
<script src="/static/options_review.js?v=19"></script>
|
||||
|
||||
Reference in New Issue
Block a user