Fix mark/PnL display fallback and intraday entry labels
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7224,6 +7224,15 @@ def api_price_snapshot():
|
||||
except Exception:
|
||||
all_swap_positions = []
|
||||
|
||||
from lib.hub.price_snapshot_lib import resolve_order_snapshot_price, seed_prices_from_positions
|
||||
|
||||
seed_prices_from_positions(
|
||||
prices,
|
||||
order_rows,
|
||||
all_swap_positions,
|
||||
resolve_ex_sym_fn=resolve_monitor_exchange_symbol,
|
||||
)
|
||||
|
||||
key_prices = []
|
||||
for r in key_rows:
|
||||
is_fib = is_fib_key_monitor_type(r["monitor_type"])
|
||||
@@ -7364,8 +7373,6 @@ def api_price_snapshot():
|
||||
})
|
||||
|
||||
order_prices = []
|
||||
from lib.hub.price_snapshot_lib import resolve_order_snapshot_price
|
||||
|
||||
for r in order_rows:
|
||||
margin = float(r["margin_capital"] or 0)
|
||||
leverage = float(r["leverage"] or 0)
|
||||
@@ -7403,7 +7410,11 @@ def api_price_snapshot():
|
||||
if ex_metrics.get("notional") is not None:
|
||||
payload["exchange_notional"] = ex_metrics["notional"]
|
||||
if ex_metrics.get("mark_price") is not None:
|
||||
payload["exchange_mark_price"] = ex_metrics["mark_price"]
|
||||
mp = ex_metrics["mark_price"]
|
||||
payload["exchange_mark_price"] = mp
|
||||
payload["exchange_mark_price_display"] = format_price_for_symbol(
|
||||
r["symbol"], mp
|
||||
)
|
||||
if ex_metrics.get("unrealized_pnl") is not None:
|
||||
payload["float_pnl"] = round(float(ex_metrics["unrealized_pnl"]), 2)
|
||||
payload["pnl_source"] = "exchange"
|
||||
@@ -7429,6 +7440,9 @@ def api_price_snapshot():
|
||||
except Exception:
|
||||
payload["price"] = px_for_fmt
|
||||
payload["price_display"] = px_disp
|
||||
if payload.get("exchange_mark_price") is None:
|
||||
payload["exchange_mark_price"] = px_for_fmt
|
||||
payload["exchange_mark_price_display"] = px_disp
|
||||
else:
|
||||
payload["price"] = None
|
||||
payload["price_display"] = "-"
|
||||
@@ -8288,6 +8302,8 @@ def add_order():
|
||||
conn.close()
|
||||
flash(style_err)
|
||||
return redirect("/trade")
|
||||
if entry_model:
|
||||
trade_style = "trend"
|
||||
available_usdt = get_available_trading_usdt()
|
||||
live_price = get_price(symbol)
|
||||
if live_price is None:
|
||||
|
||||
Reference in New Issue
Block a user