修复读取历史仓位

This commit is contained in:
dekun
2026-05-17 16:39:10 +08:00
parent 5a59246e18
commit 56f58c2b52
2 changed files with 41 additions and 37 deletions
+15 -15
View File
@@ -1732,8 +1732,12 @@ def to_effective_trade_dict(row):
item["effective_hold_seconds"] = get_effective_trade_field(row, "reviewed_hold_seconds", "hold_seconds", item.get("hold_seconds"))
er_eff = get_effective_trade_field(row, "reviewed_entry_reason", "entry_reason", item.get("entry_reason"))
item["effective_entry_reason"] = (str(er_eff).strip() if er_eff is not None else "") or ""
reviewed_pnl = get_effective_trade_field(row, "reviewed_pnl_amount", "pnl_amount", None)
has_reviewed_pnl = reviewed_pnl is not None and str(reviewed_pnl).strip() != ""
try:
_keys = row.keys() if hasattr(row, "keys") else []
except Exception:
_keys = []
_reviewed_pnl_raw = row["reviewed_pnl_amount"] if "reviewed_pnl_amount" in _keys else None
has_reviewed_pnl = _reviewed_pnl_raw is not None and str(_reviewed_pnl_raw).strip() != ""
ex_pnl = item.get("exchange_realized_pnl")
if not has_reviewed_pnl and ex_pnl is not None and str(ex_pnl).strip() != "":
try:
@@ -4508,25 +4512,21 @@ def _coerce_ts_ms(val):
if v > 1e12:
return int(v)
if v > 1e9:
return int(v)
return int(v * 1000.0)
return int(v * 1000.0)
def _unified_symbol_for_match(symbol_str):
if not symbol_str:
return ""
s = str(symbol_str).strip()
s = (symbol_str or "").strip().upper()
if not s:
return ""
try:
return normalize_exchange_symbol(s).split(":")[0]
except Exception:
x = s.upper().replace(" ", "")
if "/" in x:
return x.split(":")[0]
if x.endswith("USDT") and len(x) > 4:
return f"{x[:-4]}/USDT"
return x
if ":" in s:
s = s.split(":")[0]
if "_" in s and "/" not in s:
s = s.replace("_", "/")
if s.endswith("USDT") and "/" not in s and len(s) > 4:
s = f"{s[:-4]}/USDT"
return s
def exchange_position_sync_since_ms():