8b5080bdda
Co-authored-by: Cursor <cursoragent@cursor.com>
87 lines
2.6 KiB
Python
87 lines
2.6 KiB
Python
"""期权开平仓微信文案."""
|
|
|
|
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_usdc(self) -> None:
|
|
open_msg = build_options_open_message(
|
|
account_label="OKX期权",
|
|
inst_id="ETH-USD_UM-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,
|
|
premium_ccy="USDC",
|
|
margin_mode="usdc",
|
|
)
|
|
self.assertIn("【OKX期权·开仓】", open_msg)
|
|
self.assertIn("ETH-USD_UM-250725-3200-C", open_msg)
|
|
self.assertIn("目标指数:3400", open_msg)
|
|
self.assertIn("USDC", open_msg)
|
|
|
|
close_msg = build_options_close_message(
|
|
account_label="OKX期权",
|
|
inst_id="ETH-USD_UM-250725-3200-C",
|
|
reason="手动平仓",
|
|
underlying="ETH",
|
|
opt_type="C",
|
|
sheets=2,
|
|
premium_paid=8.5,
|
|
premium_received=12.0,
|
|
realized_pnl=3.5,
|
|
premium_ccy="USDC",
|
|
)
|
|
self.assertIn("【OKX期权·平仓】", close_msg)
|
|
self.assertIn("手动平仓", close_msg)
|
|
self.assertIn("3.5000", close_msg)
|
|
self.assertIn("USDC", close_msg)
|
|
|
|
def test_open_close_messages_coin(self) -> None:
|
|
open_msg = build_options_open_message(
|
|
account_label="OKX期权",
|
|
inst_id="ETH-USD-250725-3200-C",
|
|
underlying="ETH",
|
|
opt_type="C",
|
|
sheets=1,
|
|
premium_paid=0.001234,
|
|
open_quote=0.01234,
|
|
trade_id=99,
|
|
premium_ccy="ETH",
|
|
margin_mode="coin",
|
|
)
|
|
self.assertIn("本位:币本位", open_msg)
|
|
self.assertIn("ETH", open_msg)
|
|
self.assertNotIn("USDC", open_msg)
|
|
|
|
close_msg = build_options_close_message(
|
|
account_label="OKX期权",
|
|
inst_id="ETH-USD-250725-3200-C",
|
|
reason="翻倍出场(1倍)",
|
|
underlying="ETH",
|
|
sheets=1,
|
|
premium_paid=0.001234,
|
|
premium_received=0.0025,
|
|
realized_pnl=0.001266,
|
|
premium_ccy="ETH",
|
|
margin_mode="coin",
|
|
)
|
|
self.assertIn("本位:币本位", close_msg)
|
|
self.assertIn("翻倍出场", close_msg)
|
|
self.assertIn("ETH", close_msg)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|