Show trade record prices at exchange tick precision.
API enriches entry/SL/TP with price_to_precision display strings; OKX formatter now uses the same path as Gate/Binance. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2107,6 +2107,7 @@ def to_effective_trade_dict(row):
|
||||
|
||||
|
||||
def format_price_for_symbol(symbol, value):
|
||||
"""价格展示:与交易所 price_to_precision 一致(与入库 round_price_to_exchange 对齐)."""
|
||||
if value in (None, ""):
|
||||
return "-"
|
||||
try:
|
||||
@@ -2115,8 +2116,15 @@ def format_price_for_symbol(symbol, value):
|
||||
return str(value)
|
||||
if v == 0:
|
||||
return "0"
|
||||
try:
|
||||
ex_sym = normalize_okx_symbol(str(symbol or "").strip()) if symbol else ""
|
||||
if ex_sym:
|
||||
ensure_markets_loaded()
|
||||
return str(exchange.price_to_precision(ex_sym, v))
|
||||
except Exception:
|
||||
pass
|
||||
av = abs(v)
|
||||
# 根据币价量级动态精度:低价币保留更多小数,高价币减少噪音位数
|
||||
# 无法加载市场或无该合约时:按价格量级回退(尽量不阻断页面)
|
||||
if av >= 10000:
|
||||
d = 2
|
||||
elif av >= 100:
|
||||
@@ -9035,6 +9043,7 @@ register_trade_records_api(
|
||||
to_effective_trade_dict=to_effective_trade_dict,
|
||||
filter_trade_records_excluding_miss=filter_trade_records_excluding_miss,
|
||||
app_tz=APP_TZ,
|
||||
format_price_fn=format_price_for_symbol,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user