feat(hub): show exchange mark price on monitor positions
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""子代理持仓:四所标记价字段统一解析。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / "manual_trading_hub"))
|
||||
|
||||
from agent import _position_mark_price # noqa: E402
|
||||
|
||||
|
||||
class TestHubAgentMarkPrice(unittest.TestCase):
|
||||
def test_binance_mark_price(self):
|
||||
px = _position_mark_price({"markPrice": 65880.1, "info": {}})
|
||||
self.assertAlmostEqual(px, 65880.1)
|
||||
|
||||
def test_okx_mark_px(self):
|
||||
px = _position_mark_price({"info": {"markPx": "72.85"}})
|
||||
self.assertAlmostEqual(px, 72.85)
|
||||
|
||||
def test_gate_info_mark(self):
|
||||
px = _position_mark_price({"info": {"mark_price": "0.2241"}})
|
||||
self.assertAlmostEqual(px, 0.2241)
|
||||
|
||||
def test_missing_returns_none(self):
|
||||
self.assertIsNone(_position_mark_price({"info": {}}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user