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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user