Add expiry profit estimate and remove chain quick-buy button.

Let users enter a target index in the order panel for estimated expiry P&L, and remove the redundant buy button from the options chain row.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-07 16:46:21 +08:00
parent 2cfc1a490f
commit 27921213b0
5 changed files with 146 additions and 10 deletions
+23
View File
@@ -234,3 +234,26 @@ def format_options_breakeven_line(
if idx_px is not None and parts:
return " ".join(parts) + f"(指数{idx_px:.0f}"
return " ".join(parts)
def estimate_expiry_profit_at_index(
*,
opt_type: str,
strike: float | None,
target_idx: float | None,
entry_px: float | None,
eth_amount: float | None,
) -> float | None:
"""到期测算:目标指数价下按内在价值减权利金(每 1 币报价 × 币量)。"""
if strike is None or target_idx is None or entry_px is None or eth_amount is None:
return None
if eth_amount <= 0:
return None
o = (opt_type or "").upper()
if o == "C":
intrinsic = max(0.0, float(target_idx) - float(strike))
elif o == "P":
intrinsic = max(0.0, float(strike) - float(target_idx))
else:
return None
return round((intrinsic - float(entry_px)) * float(eth_amount), 4)
+7
View File
@@ -49,6 +49,13 @@
<div><span class="k">到期平衡</span><span id="opt-order-expiry-be" class="v"></span></div>
<div><span class="k">距平衡</span><span id="opt-order-dist-be" class="v"></span></div>
</div>
<div class="options-estimate-row">
<label class="opt-est-label" for="opt-target-idx">目标位(指数)</label>
<input type="number" id="opt-target-idx" class="opt-target-idx" step="0.1" min="0" placeholder="到期时指数价">
<span class="k">预计盈利</span>
<span id="opt-est-profit" class="v"></span>
<span class="muted opt-est-note">到期测算,仅供参考</span>
</div>
<div class="form-row options-order-mode-row">
<label><input type="radio" name="opt-size-mode" value="sheets" checked> 指定张数</label>
<input type="number" id="opt-sheets-amount" min="1" step="1" value="1" placeholder="张数">