"""对冲拆除后的冒烟:交易模式锁定单独期权;hedge_plan 包已移除.""" from __future__ import annotations import importlib import unittest class RemoveHedgeSmokeTests(unittest.TestCase): def test_trade_mode_always_options(self): from lib.options.okx_trade_mode_lib import ( get_okx_trade_mode, hedge_module_enabled, standalone_options_open_allowed, block_standalone_open_by_mode_msg, normalize_okx_trade_mode, ) self.assertEqual(normalize_okx_trade_mode("options_options"), "options") self.assertEqual(normalize_okx_trade_mode("perp_options"), "options") self.assertEqual(get_okx_trade_mode(), "options") self.assertFalse(hedge_module_enabled()) self.assertTrue(standalone_options_open_allowed()) self.assertIsNone(block_standalone_open_by_mode_msg()) def test_hedge_plan_package_gone(self): with self.assertRaises(ModuleNotFoundError): importlib.import_module("lib.hedge_plan") def test_option_expiry_pnl_available(self): from lib.options.options_pricing_lib import option_expiry_pnl pnl = option_expiry_pnl( opt_type="P", strike=2700, spot=2600, sheets=10, ct_mult=0.01, premium_paid=1.0, ) # intrinsic = 100 * 10 * 0.01 = 10; pnl = 10 - 1 = 9 self.assertAlmostEqual(pnl, 9.0, places=6) def test_profit_exit_no_hedge_import(self): import inspect from lib.options import options_profit_exit_lib as m src = inspect.getsource(m) self.assertNotIn("hedge_plan", src) if __name__ == "__main__": unittest.main()