Fix perp manual order watch_entry bug; slim dialog UI; nav shows 永期/期期.
Manual market_order was validated as watch (missing watch_entry=0). Collapse order calc into details, remove page head card, show mode name in nav. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1002,23 +1002,46 @@
|
||||
}
|
||||
|
||||
function setGateLine(gates) {
|
||||
const text = (function () {
|
||||
if (!gates) return "";
|
||||
const parts = [
|
||||
"计仓:" + (gates.is_full_margin ? "全仓" : "非全仓"),
|
||||
"测算:" + (gates.can_preview ? "可" : "否"),
|
||||
"开仓:" + (gates.can_start ? "可" : "否"),
|
||||
];
|
||||
if (gates.reasons && gates.reasons.length) parts.push(gates.reasons.join("; "));
|
||||
return parts.join(" · ");
|
||||
})();
|
||||
const el = $("hp-gate-line");
|
||||
if (!el) return;
|
||||
if (!gates) {
|
||||
el.textContent = "";
|
||||
return;
|
||||
}
|
||||
const parts = [
|
||||
"计仓:" + (gates.is_full_margin ? "全仓" : "非全仓"),
|
||||
"测算:" + (gates.can_preview ? "可" : "否"),
|
||||
"开仓:" + (gates.can_start ? "可" : "否"),
|
||||
];
|
||||
if (gates.reasons && gates.reasons.length) parts.push(gates.reasons.join("; "));
|
||||
el.textContent = parts.join(" · ");
|
||||
state.canStart = !!gates.can_start;
|
||||
if (el) el.textContent = text;
|
||||
const inline = $("hp-po-gate-inline");
|
||||
if (inline) inline.textContent = text;
|
||||
state.canStart = !!(gates && gates.can_start);
|
||||
syncPreviewStartBtn();
|
||||
}
|
||||
|
||||
function setPoOrderErr(msg, focusId) {
|
||||
const err = $("hp-po-order-err");
|
||||
if (err) {
|
||||
if (msg) {
|
||||
err.textContent = msg;
|
||||
err.removeAttribute("hidden");
|
||||
} else {
|
||||
err.textContent = "";
|
||||
err.setAttribute("hidden", "");
|
||||
}
|
||||
}
|
||||
if (focusId && $(focusId)) {
|
||||
try {
|
||||
$(focusId).focus();
|
||||
$(focusId).classList.add("hp-input-invalid");
|
||||
setTimeout(function () {
|
||||
if ($(focusId)) $(focusId).classList.remove("hp-input-invalid");
|
||||
}, 2400);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
function syncPreviewStartBtn() {
|
||||
const start = $("hp-preview-start");
|
||||
if (!start) return;
|
||||
@@ -3150,19 +3173,41 @@
|
||||
} else {
|
||||
if (!state.selected) throw new Error("请选用期权腿");
|
||||
if (isOptionPrimary()) {
|
||||
setPoOrderErr("");
|
||||
const sized = currentOpSizing();
|
||||
if (!sized || !(sized.sheets > 0)) throw new Error("请选择期权并填写张数");
|
||||
if (!sized || !(sized.sheets > 0)) {
|
||||
setPoOrderErr("请选择期权并填写张数(≥1)", "hp-order-sheets");
|
||||
throw new Error("请选择期权并填写张数(≥1)");
|
||||
}
|
||||
const exitMode = state.exitMode === "target" ? "target" : "profit";
|
||||
let optPts = 0;
|
||||
let perpPts = 0;
|
||||
let profitTarget = 0;
|
||||
if (exitMode === "profit") {
|
||||
profitTarget = numInput("hp-profit-target", NaN);
|
||||
if (!(profitTarget > 0)) throw new Error("请填写目标盈利金额(USDT,扣双边手续费后净利)");
|
||||
if (!(profitTarget > 0)) {
|
||||
setPoOrderErr("请填写目标盈利金额(USDT,扣双边手续费后净利)", "hp-profit-target");
|
||||
throw new Error("请填写目标盈利金额(USDT,扣双边手续费后净利)");
|
||||
}
|
||||
} else {
|
||||
optPts = numInput("hp-opt-target-pts", NaN);
|
||||
perpPts = numInput("hp-perp-target-pts", NaN);
|
||||
if (!(optPts > 0) || !(perpPts > 0)) throw new Error("请填写期权/永续目标位点数(须大于0)");
|
||||
if (!(optPts > 0) || !(perpPts > 0)) {
|
||||
setPoOrderErr("请填写期权/永续目标位点数(须大于0)", !(optPts > 0) ? "hp-opt-target-pts" : "hp-perp-target-pts");
|
||||
throw new Error("请填写期权/永续目标位点数(须大于0)");
|
||||
}
|
||||
}
|
||||
if (!(state.market && state.market.exchange_symbol)) {
|
||||
setPoOrderErr("永续行情未就绪,请先点「刷新行情」");
|
||||
throw new Error("永续行情未就绪,请先点「刷新行情」");
|
||||
}
|
||||
if (!state.canStart) {
|
||||
const gateTxt =
|
||||
($("hp-po-gate-inline") && $("hp-po-gate-inline").textContent) ||
|
||||
($("hp-gate-line") && $("hp-gate-line").textContent) ||
|
||||
"请先刷新行情/检查账户";
|
||||
setPoOrderErr("门禁未满足,不可开仓: " + gateTxt);
|
||||
throw new Error("门禁未满足,不可开仓: " + gateTxt);
|
||||
}
|
||||
const exp = currentExp("hp-exp-select");
|
||||
const entry = indexPx() || Number((state.market && state.market.mark) || 0);
|
||||
@@ -3174,6 +3219,7 @@
|
||||
plan_type: "perp_options",
|
||||
option_primary: true,
|
||||
market_order: 1,
|
||||
watch_entry: 0,
|
||||
exit_mode: exitMode,
|
||||
underlying: state.underlying,
|
||||
direction: getDirection(),
|
||||
|
||||
Reference in New Issue
Block a user