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
+38
View File
@@ -0,0 +1,38 @@
"""OKX 持仓指标解析:未实现盈亏须支持负数."""
from __future__ import annotations
import unittest
class TestOkxPositionMetrics(unittest.TestCase):
def test_parse_unrealized_pnl_negative(self):
from crypto_monitor_okx.app import parse_ccxt_position_metrics
pos = {
"side": "long",
"contracts": 10,
"markPrice": 0.43,
"unrealizedPnl": -1.25,
"info": {"upl": "-1.25", "markPx": "0.43"},
}
out = parse_ccxt_position_metrics(pos, order_leverage=5)
self.assertIsNotNone(out)
self.assertAlmostEqual(out["unrealized_pnl"], -1.25)
self.assertAlmostEqual(out["mark_price"], 0.43)
def test_parse_unrealized_pnl_zero(self):
from crypto_monitor_okx.app import parse_ccxt_position_metrics
pos = {
"side": "long",
"contracts": 1,
"unrealizedPnl": 0,
"info": {"upl": "0"},
}
out = parse_ccxt_position_metrics(pos)
self.assertIsNotNone(out)
self.assertEqual(out["unrealized_pnl"], 0.0)
if __name__ == "__main__":
unittest.main()