Settle expiry options at intrinsic value like live exchange.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -50,16 +50,17 @@ perp_fill = float(p_close["fill_px"])
|
||||
spot = perp_fill / (1.0 + FEE)
|
||||
intrinsic = max(spot - strike, 0.0) if str(g["option_side"])=="call" else max(strike - spot, 0.0)
|
||||
old_base = float(o_close["base_px"] or o_close["fill_px"])
|
||||
new_base = max(old_base, intrinsic)
|
||||
if abs(new_base - old_base) < 1e-9:
|
||||
# 到期对齐实盘:严格内在价值,无盘口滑点
|
||||
new_base = intrinsic
|
||||
new_fill = intrinsic
|
||||
if abs(new_base - old_base) < 1e-9 and abs(float(o_close["fill_px"]) - new_fill) < 1e-9:
|
||||
print("already ok", old_base, intrinsic)
|
||||
raise SystemExit(0)
|
||||
|
||||
qty = float(o_close["qty_eth"])
|
||||
new_fill = new_base * (1.0 - FEE)
|
||||
new_notional = new_fill * qty
|
||||
new_fee = new_notional * FEE
|
||||
new_slip = abs(new_fill - new_base) * qty
|
||||
new_slip = 0.0
|
||||
old_cash = float(o_close["notional"]) - float(o_close["fee"])
|
||||
new_cash = new_notional - new_fee
|
||||
cash_delta = new_cash - old_cash
|
||||
|
||||
Reference in New Issue
Block a user