fix: show header realtime PnL from exchange positions and order metrics
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7205,6 +7205,9 @@ def api_account_snapshot():
|
||||
position_limit_count = count_position_limit_active_monitors(conn)
|
||||
opens_today = count_opens_for_trading_day(conn, trading_day)
|
||||
risk_status = hub_account_risk_status(conn)
|
||||
active_pnl_rows = conn.execute(
|
||||
"SELECT exchange_symbol, symbol, direction FROM order_monitors WHERE status='active'"
|
||||
).fetchall()
|
||||
conn.close()
|
||||
can_trade = can_trade_new_open(
|
||||
time_allows=trading_day_reset_allows_new_open(now),
|
||||
@@ -7217,7 +7220,7 @@ def api_account_snapshot():
|
||||
available_trading_usdt = get_available_trading_usdt()
|
||||
unrealized_pnl = None
|
||||
if exchange_private_api_configured():
|
||||
from lib.instance.instance_live_pnl_lib import fetch_unrealized_pnl
|
||||
from lib.instance.instance_live_pnl_lib import resolve_instance_unrealized_pnl
|
||||
|
||||
def _gate_positions():
|
||||
ensure_markets_loaded()
|
||||
@@ -7226,7 +7229,11 @@ def api_account_snapshot():
|
||||
except Exception:
|
||||
return exchange.fetch_positions() or []
|
||||
|
||||
unrealized_pnl = fetch_unrealized_pnl(_gate_positions)
|
||||
unrealized_pnl = resolve_instance_unrealized_pnl(
|
||||
_gate_positions,
|
||||
active_pnl_rows,
|
||||
get_live_position_exchange_metrics,
|
||||
)
|
||||
return jsonify({
|
||||
"funding_usdt": funding_usdt,
|
||||
"current_capital": current_capital,
|
||||
|
||||
Reference in New Issue
Block a user