51b8bb8f8a
Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
687 B
Python
20 lines
687 B
Python
"""期权买一流动性:张数 × ctMult 是否覆盖名义 ETH。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def contracts_for_eth(qty_eth: float, ct_mult: float) -> float:
|
|
m = float(ct_mult) if ct_mult and ct_mult > 0 else 0.01
|
|
return float(qty_eth) / m
|
|
|
|
|
|
def eth_from_contracts(contracts: float, ct_mult: float) -> float:
|
|
m = float(ct_mult) if ct_mult and ct_mult > 0 else 0.01
|
|
return float(contracts) * m
|
|
|
|
|
|
def bid_covers_eth(*, bid_sz_contracts: float | None, ct_mult: float, need_eth: float) -> bool:
|
|
if bid_sz_contracts is None or bid_sz_contracts <= 0:
|
|
return False
|
|
return eth_from_contracts(bid_sz_contracts, ct_mult) + 1e-12 >= float(need_eth)
|