This commit is contained in:
薇薇安 2026-02-16 12:13:44 +08:00
parent a402007b99
commit c7e39ec1a4

View File

@ -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