划转默认折叠,修复币本位到期平衡计算
币本位权利金为币报价,到期平衡按 OKX 结算公式 K/(1±p) 计算;链/持仓/跨式平衡带同步修正。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -331,6 +331,37 @@ def test_expiry_breakeven_call_put():
|
||||
assert expiry_breakeven_px(opt_type="P", strike=3500, avg_px=15.6) == 3484.4
|
||||
|
||||
|
||||
def test_expiry_breakeven_coin_margin():
|
||||
from lib.options.options_pricing_lib import expiry_breakeven_from_ask, expiry_breakeven_px
|
||||
|
||||
# ETH-USD 币本位:卖一 0.0165 → 到期平衡 K/(1-p),非 K+p
|
||||
assert expiry_breakeven_px(
|
||||
opt_type="C", strike=2390, avg_px=0.0165, margin_mode="coin"
|
||||
) == round(2390 / (1 - 0.0165), 2)
|
||||
assert expiry_breakeven_px(
|
||||
opt_type="P", strike=2450, avg_px=0.0161, margin_mode="coin"
|
||||
) == round(2450 / (1 + 0.0161), 2)
|
||||
assert expiry_breakeven_from_ask(
|
||||
opt_type="C",
|
||||
strike=2425,
|
||||
ask_px=0.0187,
|
||||
inst_id="ETH-USD-260823-2425-C",
|
||||
) == round(2425 / (1 - 0.0187), 2)
|
||||
|
||||
|
||||
def test_straddle_breakeven_band_coin():
|
||||
from lib.options.options_pricing_lib import straddle_breakeven_band
|
||||
|
||||
lo, hi = straddle_breakeven_band(
|
||||
2425,
|
||||
quote_in_coin=True,
|
||||
call_ask=0.0187,
|
||||
put_ask=0.0253,
|
||||
)
|
||||
assert lo == round(2425 / (1 + 0.0253), 2)
|
||||
assert hi == round(2425 / (1 - 0.0187), 2)
|
||||
|
||||
|
||||
def test_close_breakeven_at_mark_equals_avg():
|
||||
from lib.options.options_pricing_lib import close_breakeven_idx
|
||||
|
||||
|
||||
Reference in New Issue
Block a user