Improve options order estimates and chain filter defaults.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user