Extend semi-auto with ITM/ATM/OTM, offset, and 1:4 sizing.
Moneyness and perp:option units are plan-only; OTM enforces leverage >=180. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -76,10 +76,27 @@ def size_and_gate(
|
||||
if not rs.ok:
|
||||
return OpenPrepResult(ok=False, detail=rs.detail, sizing_detail=rs.detail)
|
||||
else:
|
||||
from ..sim.ledger import Ledger
|
||||
from .risk_sizing import is_risk_based
|
||||
from .semi_auto import is_semi_auto, read_semi_params
|
||||
|
||||
led = Ledger(database)
|
||||
semi_perp = None
|
||||
semi_opt = None
|
||||
if is_semi_auto(led):
|
||||
sp = read_semi_params(led)
|
||||
semi_perp = float(sp["perp_unit"])
|
||||
semi_opt = float(sp["option_unit"])
|
||||
if not is_risk_based(led):
|
||||
# 手动仓:半自动直接写入 永续:期权 配比名义
|
||||
database.set_setting("perp_qty_eth", f"{semi_perp:.4f}")
|
||||
database.set_setting("option_qty_eth", f"{semi_opt:.4f}")
|
||||
rs = apply_risk_sizing_to_ledger(
|
||||
index_px=float(index_px),
|
||||
option_ask=float(option_ask),
|
||||
db=database,
|
||||
perp_unit=semi_perp,
|
||||
option_unit=semi_opt,
|
||||
)
|
||||
if not rs.ok:
|
||||
return OpenPrepResult(ok=False, detail=rs.detail, sizing_detail=rs.detail)
|
||||
|
||||
Reference in New Issue
Block a user