fix(order): hide estimated RR preview in fixed RR SLTP mode

Only price and percentage modes show estimated profit-loss ratio before open; fixed RR mode keeps the existing estimated take-profit display.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-16 16:26:18 +08:00
parent f9257b64e4
commit 58e940629a
6 changed files with 19 additions and 36 deletions
+1 -1
View File
@@ -810,7 +810,7 @@
<script src="/static/time_close_ui.js?v=2"></script>
<script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script>
<script src="/static/manual_order_rr_preview.js?v=1"></script>
<script src="/static/manual_order_rr_preview.js?v=2"></script>
<script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
+1 -1
View File
@@ -790,7 +790,7 @@
<script src="/static/time_close_ui.js?v=2"></script>
<script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script>
<script src="/static/manual_order_rr_preview.js?v=1"></script>
<script src="/static/manual_order_rr_preview.js?v=2"></script>
<script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
+1 -1
View File
@@ -790,7 +790,7 @@
<script src="/static/time_close_ui.js?v=2"></script>
<script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script>
<script src="/static/manual_order_rr_preview.js?v=1"></script>
<script src="/static/manual_order_rr_preview.js?v=2"></script>
<script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
+1 -1
View File
@@ -819,7 +819,7 @@
<script src="/static/time_close_ui.js?v=2"></script>
<script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script>
<script src="/static/manual_order_rr_preview.js?v=1"></script>
<script src="/static/manual_order_rr_preview.js?v=2"></script>
<script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
+1 -1
View File
@@ -6,7 +6,7 @@
- **价格模式**:填完币种、方向、止损价、止盈价后,调用 `GET /api/order_defaults` 取标记价,按几何距离计算 RR。
- **百分比模式**:填完币种、方向、止损%、止盈% 后拉快照校验币种,再显示 RR(`止盈% / 止损%`)。
- **固定盈亏比模式**填完币种、方向、止损价、盈亏比后取价校验几何合法,展示填写的盈亏比
- **固定盈亏比模式**不显示预估盈亏比(盈亏比由输入框直接指定;仍保留原有「预估止盈」)
与计仓方式无关:**以损定仓**`POSITION_SIZING_MODE=risk`)与 **全仓杠杆**`full_margin`)均显示同一预估。
+14 -31
View File
@@ -1,6 +1,6 @@
/**
* 实盘下单币种 + 止盈止损填完后拉 /api/order_defaults 快照在开仓按钮前显示预估盈亏比
* 价格 / 百分比 / 固定盈亏比模式与以损定仓全仓杠杆计仓方式无关
* 价格 / 百分比模式固定盈亏比模式沿预估止盈不显示预估盈亏比
*/
(function (global) {
"use strict";
@@ -47,19 +47,6 @@
return tp / sl;
}
function calcTpFromFixedRr(direction, entry, sl, rr) {
const e = num(entry);
const s = num(sl);
const r = num(rr);
if (e === null || s === null || r === null || r <= 0) return null;
if (direction === "short") {
if (s <= e) return null;
return e - (s - e) * r;
}
if (s >= e) return null;
return e + (e - s) * r;
}
function currentMode() {
return ($("sltp-mode") && $("sltp-mode").value) || "fixed_rr";
}
@@ -80,21 +67,21 @@
const tp = num($("order-tp-pct") && $("order-tp-pct").value);
return sl !== null && tp !== null && sl > 0 && tp > 0;
}
if (m === "fixed_rr") {
const sl = num($("order-sl") && $("order-sl").value);
const rr = num($("order-fixed-rr") && $("order-fixed-rr").value);
return sl !== null && rr !== null && sl > 0 && rr > 0;
}
const sl = num($("order-sl") && $("order-sl").value);
const tp = num($("order-tp") && $("order-tp").value);
return sl !== null && tp !== null && sl > 0 && tp > 0;
}
function hidePreview() {
const el = $("order-rr-preview");
if (el) el.style.display = "none";
}
function paint(rr, state) {
const el = $("order-rr-preview");
if (!el) return;
const m = currentMode();
if (m !== "price" && m !== "pct" && m !== "fixed_rr") {
if (m === "fixed_rr" || (m !== "price" && m !== "pct")) {
el.style.display = "none";
return;
}
@@ -125,6 +112,10 @@
function refreshNow() {
const m = currentMode();
if (m === "fixed_rr") {
hidePreview();
return;
}
if (!inputsComplete(m)) {
paint(null, "empty");
return;
@@ -163,17 +154,9 @@
paint(null, "fetch_fail");
return;
}
let rr = null;
if (m === "fixed_rr") {
const sl = num($("order-sl") && $("order-sl").value);
const fixed = num($("order-fixed-rr") && $("order-fixed-rr").value);
const tp = calcTpFromFixedRr(dir, entry, sl, fixed);
rr = tp !== null ? fixed : null;
} else {
const sl = num($("order-sl") && $("order-sl").value);
const tp = num($("order-tp") && $("order-tp").value);
rr = calcRr(dir, entry, sl, tp);
}
const sl = num($("order-sl") && $("order-sl").value);
const tp = num($("order-tp") && $("order-tp").value);
const rr = calcRr(dir, entry, sl, tp);
paint(rr, rr === null ? "invalid" : "ok");
})
.catch(function () {