diff --git a/backend/api/routes/trades.py b/backend/api/routes/trades.py index 7d0e9ea..4ee6f9d 100644 --- a/backend/api/routes/trades.py +++ b/backend/api/routes/trades.py @@ -128,7 +128,11 @@ async def get_trades( trades = Trade.get_all(start_timestamp, end_timestamp, symbol, status, trade_type, exit_reason, account_id=account_id) if not include_sync: - trades = [t for t in trades if (t.get("entry_reason") or "") != "sync_recovered"] + trades = [ + t for t in trades + if (t.get("entry_reason") or "") != "sync_recovered" + and (t.get("exit_reason") or "") != "sync" + ] logger.info(f"查询到 {len(trades)} 条交易记录(include_sync={include_sync})") # 格式化交易记录,添加平仓类型的中文显示 @@ -226,7 +230,11 @@ async def get_trade_stats( trades = Trade.get_all(start_timestamp, end_timestamp, symbol, None, account_id=account_id) if not include_sync: - trades = [t for t in trades if (t.get("entry_reason") or "") != "sync_recovered"] + trades = [ + t for t in trades + if (t.get("entry_reason") or "") != "sync_recovered" + and (t.get("exit_reason") or "") != "sync" + ] closed_trades = [t for t in trades if t['status'] == 'closed'] # 辅助函数:计算净盈亏(优先使用 realized_pnl - commission)