diff --git a/backend/api/routes/trades.py b/backend/api/routes/trades.py index 00682ee..bbab5a4 100644 --- a/backend/api/routes/trades.py +++ b/backend/api/routes/trades.py @@ -406,7 +406,7 @@ async def sync_trades_from_binance( - sync_all_symbols=False: 仅对「DB 中近期有记录的 symbol」拉取订单(默认,避免全市场请求) """ try: - logger.info(f"开始从币安同步历史订单(最近{days}天)...") + logger.info(f"开始从币安同步历史订单(最近{days}天,sync_all_symbols={sync_all_symbols},account_id={account_id or DEFAULT_ACCOUNT_ID})...") # 导入必要的模块 trading_system_path = project_root / 'trading_system' @@ -524,6 +524,8 @@ async def sync_trades_from_binance( logger.warning(f" [{idx}/{len(symbol_list)}] 获取 {symbol} 订单失败: {e}") continue logger.info(f"✓ 从币安获取到 {len(all_orders)} 个已成交订单(涉及 {len(symbol_list)} 个交易对)") + if len(all_orders) == 0: + logger.warning(f"⚠️ 从币安获取到的订单数为 0,可能原因:1) 时间范围内确实没有订单 2) 交易对列表为空 3) API 调用失败。时间范围: {datetime.fromtimestamp(start_ts_sec)} 至 {datetime.fromtimestamp(end_ts_sec)}") except Exception as e: logger.error(f"获取币安订单失败: {e}", exc_info=True) raise HTTPException(status_code=500, detail=f"获取币安订单失败: {str(e)}")