Show live hedge budget buffer ratio in options-options rule tips.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6791,6 +6791,7 @@ def render_main_page(page="trade", embed_mode=None):
|
||||
in ("1", "true", "yes", "on"),
|
||||
hedge_plan_oo_close_mode_enabled=os.getenv("HEDGE_PLAN_OO_CLOSE_MODE_ENABLED", "true").lower()
|
||||
in ("1", "true", "yes", "on"),
|
||||
hedge_plan_budget_buffer=float(os.getenv("HEDGE_PLAN_BUDGET_BUFFER") or "0.95"),
|
||||
options_trade_budget=OKX_OPTIONS_TRADE_BUDGET_USDC,
|
||||
options_default_underly=OKX_OPTIONS_DEFAULT_UNDERLY,
|
||||
options_chain_ask_liq_filter=os.getenv(
|
||||
|
||||
@@ -37,7 +37,11 @@
|
||||
tradingUsdc: null,
|
||||
fundingUsdc: null,
|
||||
tradeBudgetUsdc: null,
|
||||
budgetBuffer: 0.95,
|
||||
budgetBuffer: (function () {
|
||||
const raw = root.getAttribute("data-budget-buffer");
|
||||
const n = raw != null && raw !== "" ? Number(raw) : NaN;
|
||||
return !Number.isNaN(n) && n > 0 ? n : 0.95;
|
||||
})(),
|
||||
previewOk: false,
|
||||
canStart: false,
|
||||
previewPlanType: null,
|
||||
@@ -239,6 +243,15 @@
|
||||
if (modal) modal.hidden = true;
|
||||
}
|
||||
|
||||
function applyBudgetBuffer(raw) {
|
||||
if (raw == null || raw === "") return;
|
||||
const buf = Number(raw);
|
||||
if (Number.isNaN(buf) || buf <= 0) return;
|
||||
state.budgetBuffer = buf;
|
||||
const el = $("hp-oo-buf-ratio");
|
||||
if (el) el.textContent = fmt(buf, 2);
|
||||
}
|
||||
|
||||
function setOptionsBalance(chain) {
|
||||
const acct = (chain && chain.options_account) || {};
|
||||
const label = (chain && chain.account_label) || acct.label || "期权账户";
|
||||
@@ -254,8 +267,7 @@
|
||||
state.tradeBudgetUsdc = Number(chain.trade_budget_usdc);
|
||||
}
|
||||
if (chain && chain.budget_buffer != null && chain.budget_buffer !== "") {
|
||||
const buf = Number(chain.budget_buffer);
|
||||
if (!Number.isNaN(buf) && buf > 0) state.budgetBuffer = buf;
|
||||
applyBudgetBuffer(chain.budget_buffer);
|
||||
}
|
||||
const line =
|
||||
label +
|
||||
@@ -528,6 +540,7 @@
|
||||
if (d.oo_bias_ratio != null && Number(d.oo_bias_ratio) > 0 && Number(d.oo_bias_ratio) < 1) {
|
||||
state.ooBiasRatio = Number(d.oo_bias_ratio);
|
||||
}
|
||||
if (d.budget_buffer != null) applyBudgetBuffer(d.budget_buffer);
|
||||
syncOoCloseModeUI();
|
||||
setGateLine(d);
|
||||
if (state.mode === "options_options") autoFillOoSheets();
|
||||
@@ -1824,6 +1837,7 @@
|
||||
syncPoDirUI();
|
||||
syncOoSizeModeUI();
|
||||
syncOoCloseModeUI();
|
||||
applyBudgetBuffer(state.budgetBuffer);
|
||||
updateOoBudgetLine(null);
|
||||
bind();
|
||||
void refreshAll();
|
||||
|
||||
@@ -209,6 +209,7 @@ def _gates_public(cfg: dict[str, Any], plan_type: str) -> dict[str, Any]:
|
||||
g["oo_close_mode_default"] = "close_all" if _oo_close_mode_enabled() else "hold_expiry"
|
||||
g["oo_bias_split_by"] = _oo_bias_split_by()
|
||||
g["oo_bias_ratio"] = _oo_bias_ratio()
|
||||
g["budget_buffer"] = float(cfg.get("budget_buffer") or 0.95)
|
||||
return g
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
data-show-perp="{{ '1' if hedge_plan_show_perp_options | default(true) else '0' }}"
|
||||
data-show-oo="{{ '1' if hedge_plan_show_options_options | default(true) else '0' }}"
|
||||
data-oo-close-mode-enabled="{{ '1' if hedge_plan_oo_close_mode_enabled | default(true) else '0' }}"
|
||||
data-budget-buffer="{{ hedge_plan_budget_buffer | default(0.95) }}"
|
||||
data-sizing-mode="{{ position_sizing_mode | default('risk') }}"
|
||||
data-is-full-margin="{{ '1' if position_sizing_mode == 'full_margin' else '0' }}">
|
||||
{% if not hedge_plan_enabled %}
|
||||
@@ -132,7 +133,7 @@
|
||||
<details class="tip-collapse hp-rule-collapse">
|
||||
<summary class="tip-collapse-summary">规则说明</summary>
|
||||
<div class="tip-collapse-body rule-tip">
|
||||
<p><strong>账户</strong>:两腿都在<strong>期权账户</strong>。可用预算 = min(交易 USDC × 对冲缓冲, 单笔预算);缓冲在 env「对冲预算缓冲比例」改。</p>
|
||||
<p><strong>账户</strong>:两腿都在<strong>期权账户</strong>。可用预算 = min(交易 USDC × 对冲缓冲 <strong id="hp-oo-buf-ratio">{{ '%.2f'|format(hedge_plan_budget_buffer|default(0.95)|float) }}</strong>, 单笔预算);可在 env「对冲预算缓冲比例」改。</p>
|
||||
<p><strong>下单</strong>:选 Call + Put 后「计算」再「启动」。启动会再拉卖一并按最新价重算张数,IOC 完全成交才算成功;资金不足可在右侧划转。</p>
|
||||
<p><strong>板块</strong>:左填上破/下破与张数模式(同张数/做多/做空);右 T 型选腿。「全平」= 盈利腿平后清另一腿;「到期平」= 另一腿持有至到期。</p>
|
||||
</div>
|
||||
@@ -321,4 +322,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/hedge_plan.js?v=32"></script>
|
||||
<script src="/static/hedge_plan.js?v=33"></script>
|
||||
|
||||
Reference in New Issue
Block a user