fix(hub): align Binance chart ticks and improve monitor mark price

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-03 22:33:59 +08:00
parent c1fda1e7d5
commit 2a9602610e
7 changed files with 275 additions and 30 deletions
+13 -1
View File
@@ -8,7 +8,7 @@ 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
from agent import _position_mark_price, _ticker_mark_price # noqa: E402
class TestHubAgentMarkPrice(unittest.TestCase):
@@ -27,6 +27,18 @@ class TestHubAgentMarkPrice(unittest.TestCase):
def test_missing_returns_none(self):
self.assertIsNone(_position_mark_price({"info": {}}))
def test_infer_from_notional_and_contracts(self):
p = {"notional": 1000, "contracts": 10, "info": {}}
px = _position_mark_price(p)
self.assertAlmostEqual(px, 100.0)
def test_ticker_fallback(self):
class _Ex:
def fetch_ticker(self, sym):
return {"mark": 99.5, "info": {}}
self.assertAlmostEqual(_ticker_mark_price(_Ex(), "BTC/USDT:USDT"), 99.5)
if __name__ == "__main__":
unittest.main()