Split OO budget per leg and size Call/Put independently.

Each half of the risk budget buys its own qty from ask; equal qty no longer forced.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-07 17:08:05 +08:00
parent 24943adf13
commit 24a860ad3f
11 changed files with 210 additions and 110 deletions
+16 -14
View File
@@ -426,22 +426,23 @@ class Matcher:
return OpenResult(ok=False, detail="期期 Call/Put 卖一不可用")
fee_rate = self._fee_rate()
opt_qty = self.ledger.get_setting_float("option_qty_eth", 0.1)
if opt_qty < 0.1 - 1e-12:
call_qty = self.ledger.get_setting_float("option_qty_eth", 0.1)
put_qty = self.ledger.get_setting_float("oo_put_qty_eth", call_qty)
if call_qty < 0.1 - 1e-12 or put_qty < 0.1 - 1e-12:
return OpenResult(ok=False, detail="期期名义 qty 无效")
call_ct = self._ct_mult(call_inst_id)
put_ct = self._ct_mult(put_inst_id)
call_contracts = contracts_for_eth(opt_qty, call_ct)
put_contracts = contracts_for_eth(opt_qty, put_ct)
call_contracts = contracts_for_eth(call_qty, call_ct)
put_contracts = contracts_for_eth(put_qty, put_ct)
cf = option_fill(
action="open",
bid=float(getattr(cq, "bid", None) or 0),
ask=float(cq.ask),
qty_eth=opt_qty,
qty_eth=call_qty,
fee_rate=fee_rate,
)
call_prem = cf.fill_px * opt_qty
call_prem = cf.fill_px * call_qty
call_cost = cf.notional + cf.fee
try:
self.ledger.apply_cash(
@@ -460,10 +461,10 @@ class Matcher:
action="open",
bid=float(getattr(pq2, "bid", None) or 0),
ask=ask2,
qty_eth=opt_qty,
qty_eth=put_qty,
fee_rate=fee_rate,
)
put_prem = pf.fill_px * opt_qty
put_prem = pf.fill_px * put_qty
put_cost = pf.notional + pf.fee
try:
self.ledger.apply_cash(
@@ -479,7 +480,7 @@ class Matcher:
action="close",
bid=bid,
ask=float(cq.ask),
qty_eth=opt_qty,
qty_eth=call_qty,
fee_rate=fee_rate,
)
self.ledger.apply_cash(
@@ -532,7 +533,7 @@ class Matcher:
"open",
"long",
call_inst_id,
opt_qty,
call_qty,
call_contracts,
cf.base_px,
cf.fill_px,
@@ -553,7 +554,7 @@ class Matcher:
"open",
"long",
put_inst_id,
opt_qty,
put_qty,
put_contracts,
pf.base_px,
pf.fill_px,
@@ -576,7 +577,7 @@ class Matcher:
group_id,
call_inst_id,
"call",
opt_qty,
call_qty,
call_contracts,
cf.fill_px,
entry_index_px,
@@ -585,7 +586,7 @@ class Matcher:
"option_option",
put_inst_id,
"put",
opt_qty,
put_qty,
put_contracts,
pf.fill_px,
float(put_strike),
@@ -614,7 +615,8 @@ class Matcher:
"put_inst_id": put_inst_id,
"call_strike": float(call_strike),
"put_strike": float(put_strike),
"option_qty_eth": float(opt_qty),
"option_qty_eth": float(call_qty),
"option2_qty_eth": float(put_qty),
"initial_premium": total_prem,
"fees": cf.fee + pf.fee,
"open_sequence": ["call", "put"],