"""期权开平仓微信文案.""" from __future__ import annotations import unittest from lib.options.options_notify_lib import ( build_options_close_message, build_options_open_message, ) class TestOptionsNotify(unittest.TestCase): def test_open_close_messages(self) -> None: open_msg = build_options_open_message( account_label="OKX期权", inst_id="ETH-USD-250725-3200-C", underlying="ETH", opt_type="C", sheets=2, premium_paid=8.5, open_quote=0.01, target_index=3400, signal_note="假突破", trade_id=12, ) self.assertIn("【OKX期权·开仓】", open_msg) self.assertIn("ETH-USD-250725-3200-C", open_msg) self.assertIn("目标指数:3400", open_msg) close_msg = build_options_close_message( account_label="OKX期权", inst_id="ETH-USD-250725-3200-C", reason="手动平仓", underlying="ETH", opt_type="C", sheets=2, premium_paid=8.5, premium_received=12.0, realized_pnl=3.5, ) self.assertIn("【OKX期权·平仓】", close_msg) self.assertIn("手动平仓", close_msg) self.assertIn("3.5000", close_msg) if __name__ == "__main__": unittest.main()