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(