Initial CoinOX instance: coin-margined options + USDT hedge.

Forked from crypto_monitor OKX instance (copy-only). Keeps standalone options, perp-options and options-options hedge; drops standalone perp entrypoints; forces coin margin; adds sim wallets; default port 5010.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-14 00:18:40 +08:00
commit 88b7fb7a0a
381 changed files with 104628 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
"""期权开平仓微信文案."""
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()