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:
@@ -810,7 +810,7 @@
|
|||||||
<script src="/static/time_close_ui.js?v=2"></script>
|
<script src="/static/time_close_ui.js?v=2"></script>
|
||||||
<script src="/static/ai_review_render.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/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>
|
<script>
|
||||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||||
|
|||||||
@@ -790,7 +790,7 @@
|
|||||||
<script src="/static/time_close_ui.js?v=2"></script>
|
<script src="/static/time_close_ui.js?v=2"></script>
|
||||||
<script src="/static/ai_review_render.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/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>
|
<script>
|
||||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||||
|
|||||||
@@ -790,7 +790,7 @@
|
|||||||
<script src="/static/time_close_ui.js?v=2"></script>
|
<script src="/static/time_close_ui.js?v=2"></script>
|
||||||
<script src="/static/ai_review_render.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/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>
|
<script>
|
||||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||||
|
|||||||
@@ -819,7 +819,7 @@
|
|||||||
<script src="/static/time_close_ui.js?v=2"></script>
|
<script src="/static/time_close_ui.js?v=2"></script>
|
||||||
<script src="/static/ai_review_render.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/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>
|
<script>
|
||||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
- **价格模式**:填完币种、方向、止损价、止盈价后,调用 `GET /api/order_defaults` 取标记价,按几何距离计算 RR。
|
- **价格模式**:填完币种、方向、止损价、止盈价后,调用 `GET /api/order_defaults` 取标记价,按几何距离计算 RR。
|
||||||
- **百分比模式**:填完币种、方向、止损%、止盈% 后拉快照校验币种,再显示 RR(`止盈% / 止损%`)。
|
- **百分比模式**:填完币种、方向、止损%、止盈% 后拉快照校验币种,再显示 RR(`止盈% / 止损%`)。
|
||||||
- **固定盈亏比模式**:填完币种、方向、止损价、盈亏比后取价校验几何合法,展示填写的盈亏比。
|
- **固定盈亏比模式**:不显示预估盈亏比(盈亏比由输入框直接指定;仍保留原有「预估止盈」)。
|
||||||
|
|
||||||
与计仓方式无关:**以损定仓**(`POSITION_SIZING_MODE=risk`)与 **全仓杠杆**(`full_margin`)均显示同一预估。
|
与计仓方式无关:**以损定仓**(`POSITION_SIZING_MODE=risk`)与 **全仓杠杆**(`full_margin`)均显示同一预估。
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* 实盘下单:币种 + 止盈止损填完后拉 /api/order_defaults 快照,在开仓按钮前显示预估盈亏比。
|
* 实盘下单:币种 + 止盈止损填完后拉 /api/order_defaults 快照,在开仓按钮前显示预估盈亏比。
|
||||||
* 价格 / 百分比 / 固定盈亏比模式通用;与以损定仓、全仓杠杆计仓方式无关。
|
* 仅价格 / 百分比模式;固定盈亏比模式沿用「预估止盈」,不显示预估盈亏比。
|
||||||
*/
|
*/
|
||||||
(function (global) {
|
(function (global) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -47,19 +47,6 @@
|
|||||||
return tp / sl;
|
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() {
|
function currentMode() {
|
||||||
return ($("sltp-mode") && $("sltp-mode").value) || "fixed_rr";
|
return ($("sltp-mode") && $("sltp-mode").value) || "fixed_rr";
|
||||||
}
|
}
|
||||||
@@ -80,21 +67,21 @@
|
|||||||
const tp = num($("order-tp-pct") && $("order-tp-pct").value);
|
const tp = num($("order-tp-pct") && $("order-tp-pct").value);
|
||||||
return sl !== null && tp !== null && sl > 0 && tp > 0;
|
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 sl = num($("order-sl") && $("order-sl").value);
|
||||||
const tp = num($("order-tp") && $("order-tp").value);
|
const tp = num($("order-tp") && $("order-tp").value);
|
||||||
return sl !== null && tp !== null && sl > 0 && tp > 0;
|
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) {
|
function paint(rr, state) {
|
||||||
const el = $("order-rr-preview");
|
const el = $("order-rr-preview");
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
const m = currentMode();
|
const m = currentMode();
|
||||||
if (m !== "price" && m !== "pct" && m !== "fixed_rr") {
|
if (m === "fixed_rr" || (m !== "price" && m !== "pct")) {
|
||||||
el.style.display = "none";
|
el.style.display = "none";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -125,6 +112,10 @@
|
|||||||
|
|
||||||
function refreshNow() {
|
function refreshNow() {
|
||||||
const m = currentMode();
|
const m = currentMode();
|
||||||
|
if (m === "fixed_rr") {
|
||||||
|
hidePreview();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!inputsComplete(m)) {
|
if (!inputsComplete(m)) {
|
||||||
paint(null, "empty");
|
paint(null, "empty");
|
||||||
return;
|
return;
|
||||||
@@ -163,17 +154,9 @@
|
|||||||
paint(null, "fetch_fail");
|
paint(null, "fetch_fail");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let rr = null;
|
const sl = num($("order-sl") && $("order-sl").value);
|
||||||
if (m === "fixed_rr") {
|
const tp = num($("order-tp") && $("order-tp").value);
|
||||||
const sl = num($("order-sl") && $("order-sl").value);
|
const rr = calcRr(dir, entry, sl, tp);
|
||||||
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);
|
|
||||||
}
|
|
||||||
paint(rr, rr === null ? "invalid" : "ok");
|
paint(rr, rr === null ? "invalid" : "ok");
|
||||||
})
|
})
|
||||||
.catch(function () {
|
.catch(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user