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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user