Implement P1 local matcher/ledger and P2 strategy engine.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-24 17:03:46 +08:00
parent 0fca5f025e
commit 51b8bb8f8a
30 changed files with 2086 additions and 150 deletions
+19
View File
@@ -0,0 +1,19 @@
"""期权买一流动性:张数 × 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)