Use bid1-only option closes with hard-disabled market exits.
Manual close checks liquidity only; target auto still requires 2x recycle hold once, then reuses the shared bid1 executor. Add /options/guide doc and update hedge-plan refs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -490,12 +490,13 @@
|
||||
|
||||
function closeGateHint(preview) {
|
||||
if (!preview) return "";
|
||||
if (preview.bid_invalid) {
|
||||
return preview.bid_invalid_reason || "当前买一无效,禁止按买盘自动平仓";
|
||||
if (preview.bid_invalid || preview.manual_close_blocked) {
|
||||
return preview.bid_invalid_reason || "当前买一无效,禁止买一平仓";
|
||||
}
|
||||
const gate = preview.close_gate || {};
|
||||
if (preview.close_gate_blocked || gate.ready === false) {
|
||||
return preview.close_gate_msg || gate.msg || "可回收需≥2×权利金并持续2分钟后才可平仓";
|
||||
// 2×门控仅约束目标位自动平;手动买一平仓不拦截,作状态提示
|
||||
if (preview.close_gate_blocked || (gate.ready === false && !gate.passed)) {
|
||||
return "自动平仓: " + (preview.close_gate_msg || gate.msg || "可回收需≥2×权利金并持续2分钟");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -981,7 +982,7 @@
|
||||
'<div class="pos-card-symbol"><strong>' + (p.inst_id || "") + '</strong>' +
|
||||
'<span class="pos-side-badge ' + sideCls + '">' + optTypeLabel(p.opt_type) + "</span></div>" +
|
||||
'<div class="pos-head-actions">' +
|
||||
'<button type="button" class="btn-primary opt-close-btn" data-inst="' + p.inst_id + '" data-sheets="' + closeSheets + '">多档平仓</button>' +
|
||||
'<button type="button" class="btn-primary opt-close-btn" data-inst="' + p.inst_id + '" data-sheets="' + closeSheets + '">买一平仓</button>' +
|
||||
"</div></div>" +
|
||||
'<div class="pos-meta">' +
|
||||
'<span class="pos-meta-item">行权价: ' + fmt(p.strike, 0) + "</span>" +
|
||||
@@ -1304,30 +1305,22 @@
|
||||
return;
|
||||
}
|
||||
const preview = q.close_preview || {};
|
||||
if (preview.bid_invalid) {
|
||||
alert(preview.bid_invalid_reason || "当前买一为无效残档,禁止按买盘自动平仓。请到 OKX App 自行挂限价/市价。");
|
||||
return;
|
||||
}
|
||||
if (preview.close_gate_blocked || (preview.close_gate && preview.close_gate.ready === false)) {
|
||||
alert(
|
||||
preview.close_gate_msg ||
|
||||
(preview.close_gate && preview.close_gate.msg) ||
|
||||
"可回收需≥2×权利金,并持续满2分钟后才可平仓"
|
||||
);
|
||||
if (preview.bid_invalid || preview.manual_close_blocked) {
|
||||
alert(preview.bid_invalid_reason || "当前买一为无效残档,禁止买一平仓。");
|
||||
return;
|
||||
}
|
||||
if (!preview.covered_sheets || preview.covered_sheets <= 0) {
|
||||
alert("暂无可用买盘深度,请稍后在 OKX App 平仓或等盘口恢复");
|
||||
alert("暂无有效买一深度,请稍后重试或到 OKX App 挂限价");
|
||||
return;
|
||||
}
|
||||
const lv = (preview.levels && preview.levels[0]) || {};
|
||||
const msg = [
|
||||
"按最多5档买盘拆分限价卖出?",
|
||||
"按买一限价卖出本轮可平张数?",
|
||||
"合约: " + inst,
|
||||
"锁定买一: " + (lv.px != null ? lv.px : "—") + " × " + (lv.sheets != null ? lv.sheets : preview.covered_sheets) + " 张",
|
||||
"预计收回: " + fmtClosePreviewText(preview),
|
||||
preview.estimated_pnl != null ? "预估盈亏: " + fmt(preview.estimated_pnl, 4) + " USDC" : "",
|
||||
"",
|
||||
fmtPreviewLevels(preview),
|
||||
preview.uncovered_sheets > 0 ? "\n注意: 当前买盘不足,预计仍剩 " + preview.uncovered_sheets + " 张未覆盖。" : ""
|
||||
preview.uncovered_sheets > 0 ? "\n注意: 买一深度不足,预计仍剩 " + preview.uncovered_sheets + " 张,需下次再平。" : ""
|
||||
].filter(function (x) { return x !== ""; }).join("\n");
|
||||
if (!confirm(msg)) return;
|
||||
if (btn) btn.disabled = true;
|
||||
@@ -1335,13 +1328,14 @@
|
||||
const r = await apiJson("/api/options/close", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ inst_id: inst, mode: "depth_split", sheets: sheets }),
|
||||
body: JSON.stringify({ inst_id: inst, mode: "bid1", sheets: sheets }),
|
||||
});
|
||||
if (r.ok) {
|
||||
let okMsg = "平仓单已提交 " + (r.submitted_sheets || 0) + " 张";
|
||||
let okMsg = "买一平仓已提交 " + (r.submitted_sheets || 0) + " 张";
|
||||
if (r.locked_bid_px != null) okMsg += "\n锁定买一: " + r.locked_bid_px;
|
||||
if (r.premium_received != null) okMsg += "\n预估收回: " + fmt(r.premium_received, 4) + " USDC";
|
||||
if (r.remaining_sheets > 0) okMsg += "\n剩余: " + r.remaining_sheets + " 张";
|
||||
if (r.stopped_reason) okMsg += "\n停止原因: " + r.stopped_reason;
|
||||
if (r.remaining_sheets > 0) okMsg += "\n剩余: " + r.remaining_sheets + " 张(下次再平)";
|
||||
if (r.stopped_reason) okMsg += "\n状态: " + r.stopped_reason;
|
||||
alert(okMsg);
|
||||
} else {
|
||||
alert(r.msg || "平仓失败");
|
||||
|
||||
@@ -66,12 +66,12 @@
|
||||
|
||||
function closeGateHint(preview) {
|
||||
if (!preview) return "";
|
||||
if (preview.bid_invalid) {
|
||||
return preview.bid_invalid_reason || "当前买一无效,禁止按买盘自动平仓";
|
||||
if (preview.bid_invalid || preview.manual_close_blocked) {
|
||||
return preview.bid_invalid_reason || "当前买一无效,禁止买一平仓";
|
||||
}
|
||||
const gate = preview.close_gate || {};
|
||||
if (preview.close_gate_blocked || gate.ready === false) {
|
||||
return preview.close_gate_msg || gate.msg || "可回收需≥2×权利金并持续2分钟后才可平仓";
|
||||
if (preview.close_gate_blocked || (gate.ready === false && !gate.passed)) {
|
||||
return "自动平仓: " + (preview.close_gate_msg || gate.msg || "可回收需≥2×权利金并持续2分钟");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -138,7 +138,7 @@
|
||||
const closeSheets = p.avail_pos != null && Number(p.avail_pos) > 0 ? p.avail_pos : p.pos;
|
||||
headActions =
|
||||
'<div class="pos-head-actions">' +
|
||||
'<button type="button" class="btn-primary opt-close-btn" data-inst="' + (p.inst_id || "") + '" data-sheets="' + closeSheets + '">多档平仓</button>' +
|
||||
'<button type="button" class="btn-primary opt-close-btn" data-inst="' + (p.inst_id || "") + '" data-sheets="' + closeSheets + '">买一平仓</button>' +
|
||||
"</div>";
|
||||
}
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user