fix(gate-bot): format mark price with exchange symbol precision
Use price_to_precision in price_snapshot so live mark price matches entry/SL display instead of fixed 8 decimals.
This commit is contained in:
@@ -119,6 +119,33 @@ def enrich_order_display_fields(item: dict[str, Any], calc_rr_ratio_fn: Callable
|
||||
return item
|
||||
|
||||
|
||||
def apply_order_live_price_display(
|
||||
payload: dict[str, Any],
|
||||
symbol: Any,
|
||||
ticker_price: Any,
|
||||
exchange_mark_price: Any,
|
||||
format_price_fn: Callable[[Any, Any], str],
|
||||
) -> dict[str, Any]:
|
||||
"""标记价/现价展示:与交易所 price_to_precision 对齐,避免前端 toFixed(8)。"""
|
||||
px_for_fmt = ticker_price
|
||||
mark_raw = exchange_mark_price
|
||||
if mark_raw is not None:
|
||||
try:
|
||||
px_for_fmt = float(mark_raw)
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
px_disp = format_price_fn(symbol, px_for_fmt)
|
||||
payload["price_display"] = px_disp
|
||||
if mark_raw is not None:
|
||||
try:
|
||||
payload["exchange_mark_price_display"] = format_price_fn(symbol, float(mark_raw))
|
||||
except (TypeError, ValueError):
|
||||
payload["exchange_mark_price_display"] = px_disp
|
||||
else:
|
||||
payload["exchange_mark_price_display"] = None
|
||||
return payload
|
||||
|
||||
|
||||
def apply_order_price_display_fields(
|
||||
payload: dict[str, Any],
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user