Improve options order estimates and chain filter defaults.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-11 14:37:53 +08:00
parent 9f0a30a040
commit c9c8388250
4 changed files with 204 additions and 63 deletions
+30 -5
View File
@@ -298,16 +298,15 @@ def format_options_breakeven_line(
return " ".join(parts)
def estimate_expiry_profit_at_index(
def estimate_expiry_value_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:
"""到期测算:目标指数价下期权内在价值总额(不含已付权利金)."""
if strike is None or target_idx is None or eth_amount is None:
return None
if eth_amount <= 0:
return None
@@ -318,7 +317,33 @@ def estimate_expiry_profit_at_index(
intrinsic = max(0.0, float(strike) - float(target_idx))
else:
return None
return round((intrinsic - float(entry_px)) * float(eth_amount), 4)
return round(intrinsic * float(eth_amount), 2)
def estimate_expiry_profit_at_index(
*,
opt_type: str,
strike: float | None,
target_idx: float | None,
entry_px: float | None,
eth_amount: float | None,
total_premium: float | None = None,
) -> float | None:
"""到期测算:目标指数价下净盈利 = 预计价值 − 权利金."""
value = estimate_expiry_value_at_index(
opt_type=opt_type,
strike=strike,
target_idx=target_idx,
eth_amount=eth_amount,
)
if value is None:
return None
prem = total_premium
if prem is None and entry_px is not None and eth_amount is not None:
prem = float(entry_px) * float(eth_amount)
if prem is None:
return None
return round(float(value) - float(prem), 2)
def equivalent_contract_leverage(
+7 -4
View File
@@ -14,7 +14,8 @@
<select id="opt-exp-select"><option value="">选择到期日</option></select>
<button type="button" class="btn-secondary opt-type-btn active" data-type="C">看涨 Call</button>
<button type="button" class="btn-secondary opt-type-btn" data-type="P">看跌 Put</button>
<button type="button" class="btn-secondary opt-money-btn active" data-money="itm">实值</button>
<button type="button" class="btn-secondary opt-money-btn active" data-money="all">全部</button>
<button type="button" class="btn-secondary opt-money-btn" data-money="itm">实值</button>
<button type="button" class="btn-secondary opt-money-btn" data-money="otm">虚值</button>
<button type="button" class="btn-secondary" id="opt-load-chain">刷新链</button>
</div>
@@ -46,7 +47,7 @@
<div><span class="k">卖一/张</span><span id="opt-order-ask" class="v"></span></div>
<div><span class="k">买一/张</span><span id="opt-order-bid" class="v"></span></div>
<div><span class="k">张数</span><span id="opt-order-sheets" class="v"></span></div>
<div><span class="k">ETH/BTC 数量</span><span id="opt-order-eth" class="v"></span></div>
<div><span class="k" id="opt-order-eth-label">ETH 数量</span><span id="opt-order-eth" class="v"></span></div>
<div><span class="k">预估权利金</span><span id="opt-order-premium" class="v"></span></div>
<div><span class="k">合约杠杆</span><span id="opt-order-leverage" class="v" title="名义价值÷权利金,测算用"></span></div>
<div><span class="k">到期平衡</span><span id="opt-order-expiry-be" class="v"></span></div>
@@ -55,7 +56,9 @@
<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 class="k">预计价值</span>
<span id="opt-est-value" class="v"></span>
<span class="k">盈利</span>
<span id="opt-est-profit" class="v"></span>
<span class="k">目标杠杆</span>
<span id="opt-est-leverage" class="v" title="目标位名义价值÷权利金"></span>
@@ -212,4 +215,4 @@
</div>
</div>
<script src="/static/options_expiry_countdown.js?v=1"></script>
<script src="/static/options_panel.js?v=26"></script>
<script src="/static/options_panel.js?v=27"></script>