f95118065d
Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
955 B
Python
33 lines
955 B
Python
"""子代理持仓:四所开仓价字段统一解析。"""
|
|
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_entry_price # noqa: E402
|
|
|
|
|
|
class TestHubAgentEntryPrice(unittest.TestCase):
|
|
def test_binance_entry_price(self):
|
|
px = _position_entry_price({"entryPrice": 65851.6, "info": {}})
|
|
self.assertAlmostEqual(px, 65851.6)
|
|
|
|
def test_okx_avg_px(self):
|
|
px = _position_entry_price({"info": {"avgPx": "72.731"}})
|
|
self.assertAlmostEqual(px, 72.731)
|
|
|
|
def test_gate_info_entry(self):
|
|
px = _position_entry_price({"info": {"entry_price": "0.2232"}})
|
|
self.assertAlmostEqual(px, 0.2232)
|
|
|
|
def test_missing_returns_none(self):
|
|
self.assertIsNone(_position_entry_price({"info": {}}))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|