fix(hub): live market PnL and Gate drag SL place

Parse Gate unrealised_pnl in agent; refresh hub market floating PnL from board and trends; clamp Gate TP/SL triggers before place.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-04 20:02:23 +08:00
parent 24270944e7
commit e6361a7fcc
7 changed files with 197 additions and 17 deletions
+9
View File
@@ -10,6 +10,9 @@ sys.path.insert(0, str(ROOT / "manual_trading_hub"))
from agent import _position_mark_price, _ticker_mark_price # noqa: E402
sys.path.insert(0, str(ROOT))
from hub_position_metrics import parse_position_unrealized_pnl # noqa: E402
class TestHubAgentMarkPrice(unittest.TestCase):
def test_binance_mark_price(self):
@@ -39,6 +42,12 @@ class TestHubAgentMarkPrice(unittest.TestCase):
self.assertAlmostEqual(_ticker_mark_price(_Ex(), "BTC/USDT:USDT"), 99.5)
def test_gate_unrealised_pnl_in_info(self):
pnl = parse_position_unrealized_pnl(
{"info": {"unrealised_pnl": "6.81"}, "unrealizedPnl": None}
)
self.assertAlmostEqual(pnl, 6.81)
if __name__ == "__main__":
unittest.main()