Files
crypto_monitor_user/tests/test_option_buy_liquidity.py
T
dekun 53863559f4 Initialize crypto_monitor_user (user edition) from monitor codebase.
Retarget git remote, install path, and deploy docs from crypto_monitor to crypto_monitor_user.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 16:18:13 +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