修复交易记录基数误把折算标的币数量当保证金:写入清洗+列表展示自动纠偏。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,7 +10,22 @@ def enrich_trade_price_displays(
|
||||
format_price_fn: Optional[Callable[[Any, Any], str]] = None,
|
||||
) -> dict[str, Any]:
|
||||
"""为成交/止损/止盈补交易所精度展示字段(供交易记录表直接渲染)."""
|
||||
if not format_price_fn or not isinstance(item, dict):
|
||||
if not isinstance(item, dict):
|
||||
return item
|
||||
try:
|
||||
from lib.trade.trade_margin_record_lib import repair_stored_margin_capital
|
||||
|
||||
fixed = repair_stored_margin_capital(
|
||||
item.get("margin_capital"),
|
||||
trigger_price=item.get("trigger_price"),
|
||||
leverage=item.get("leverage"),
|
||||
symbol=item.get("symbol"),
|
||||
)
|
||||
if fixed is not None:
|
||||
item["margin_capital"] = fixed
|
||||
except Exception:
|
||||
pass
|
||||
if not format_price_fn:
|
||||
return item
|
||||
sym = item.get("symbol")
|
||||
stop_show = item.get("display_open_stop_loss")
|
||||
@@ -59,8 +74,7 @@ def list_trade_records_page(
|
||||
page = pages
|
||||
offset = (page - 1) * limit
|
||||
items = records[offset : offset + limit]
|
||||
if format_price_fn is not None:
|
||||
items = [enrich_trade_price_displays(dict(it), format_price_fn) for it in items]
|
||||
items = [enrich_trade_price_displays(dict(it), format_price_fn) for it in items]
|
||||
return {
|
||||
"ok": True,
|
||||
"items": items,
|
||||
|
||||
Reference in New Issue
Block a user