Add depth-based option close flow.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -129,6 +129,42 @@ def test_format_quote_liquidity():
|
||||
assert format_quote_liquidity(None, 10) is None
|
||||
|
||||
|
||||
def test_estimate_close_by_bids_full_depth():
|
||||
from lib.options.options_pricing_lib import estimate_close_by_bids
|
||||
|
||||
out = estimate_close_by_bids(
|
||||
[{"px": 12.3, "sz": 2}, {"px": 12.1, "sz": 3}],
|
||||
4,
|
||||
ct_mult=0.01,
|
||||
premium_paid=0.4,
|
||||
)
|
||||
assert out["covered_sheets"] == 4
|
||||
assert out["uncovered_sheets"] == 0
|
||||
assert out["total_received"] == 0.488
|
||||
assert out["avg_px"] == 12.2
|
||||
assert out["estimated_pnl"] == 0.088
|
||||
assert [x["sheets"] for x in out["levels"]] == [2, 2]
|
||||
|
||||
|
||||
def test_estimate_close_by_bids_partial_depth():
|
||||
from lib.options.options_pricing_lib import estimate_close_by_bids
|
||||
|
||||
out = estimate_close_by_bids([{"px": 10, "sz": 1}], 3, ct_mult=0.01, premium_paid=0.6)
|
||||
assert out["covered_sheets"] == 1
|
||||
assert out["uncovered_sheets"] == 2
|
||||
assert out["total_received"] == 0.1
|
||||
assert out["estimated_pnl"] == -0.1
|
||||
|
||||
|
||||
def test_estimate_close_by_bids_empty():
|
||||
from lib.options.options_pricing_lib import estimate_close_by_bids
|
||||
|
||||
out = estimate_close_by_bids([], 2)
|
||||
assert out["covered_sheets"] == 0
|
||||
assert out["uncovered_sheets"] == 2
|
||||
assert out["avg_px"] is None
|
||||
|
||||
|
||||
def test_expiry_breakeven_from_ask():
|
||||
from lib.options.options_pricing_lib import expiry_breakeven_from_ask
|
||||
|
||||
|
||||
Reference in New Issue
Block a user