Files
crypto_monitor/tests/test_option_buy_liquidity.py
dekun 4686cf049a Require real ask depth for options and hedge opens.
Block mark-as-ask opens, show reference mark when no depth, cap sheets to ask size; leave close paths unchanged. Document in docs/更新文档.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 12:48:53 +08:00

23 lines
800 B
Python

"""期权买入流动性门禁:真实卖一价+深度."""
from lib.exchange.okx_options_lib import (
cap_option_buy_sheets_to_ask_depth,
option_buy_liquidity_ok,
)
def test_option_buy_liquidity_ok_requires_ask_and_depth():
assert option_buy_liquidity_ok(10, 1)[0] is True
assert option_buy_liquidity_ok(10, 0)[0] is False
assert option_buy_liquidity_ok(10, None)[0] is False
assert option_buy_liquidity_ok(None, 5)[0] is False
assert option_buy_liquidity_ok(0, 5)[0] is False
def test_cap_option_buy_sheets_to_ask_depth():
capped, msg = cap_option_buy_sheets_to_ask_depth(9, 2.8, min_sz=1)
assert capped == 2
assert msg == ""
capped, msg = cap_option_buy_sheets_to_ask_depth(1, 0.4, min_sz=1)
assert capped is None
assert "深度不足" in msg