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:
@@ -31,7 +31,7 @@ _REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(_REPO_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(_REPO_ROOT))
|
||||
from hub_ohlcv_lib import format_price_by_tick, price_tick_from_market
|
||||
from hub_position_metrics import parse_position_mark_price
|
||||
from hub_position_metrics import parse_position_mark_price, parse_position_unrealized_pnl
|
||||
|
||||
import ccxt
|
||||
from fastapi import FastAPI, Header, HTTPException, Request
|
||||
@@ -602,10 +602,8 @@ def _status_inner(x_control_token: str | None) -> Any:
|
||||
continue
|
||||
sym = p.get("symbol") or ""
|
||||
side = _position_side(p, c)
|
||||
upnl = p.get("unrealizedPnl")
|
||||
try:
|
||||
upnl_f = float(upnl) if upnl is not None else 0.0
|
||||
except (TypeError, ValueError):
|
||||
upnl_f = parse_position_unrealized_pnl(p)
|
||||
if upnl_f is None:
|
||||
upnl_f = 0.0
|
||||
total_upnl += upnl_f
|
||||
notional = p.get("notional")
|
||||
|
||||
Reference in New Issue
Block a user