From ba8396827af12e51ceaaf9ca0d998712b9e53ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Fri, 16 Jan 2026 15:43:59 +0800 Subject: [PATCH] a --- backend/requirements.txt | 3 +++ trading_system/binance_client.py | 17 +++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 5938355..8cc7376 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -15,3 +15,6 @@ python-dotenv==1.0.0 python-binance==1.0.19 websocket-client==1.6.1 aiohttp==3.9.1 + +# Redis/Valkey 缓存依赖(与 trading_system 保持一致) +aioredis==2.0.1 diff --git a/trading_system/binance_client.py b/trading_system/binance_client.py index 3aeabef..ab23e43 100644 --- a/trading_system/binance_client.py +++ b/trading_system/binance_client.py @@ -668,19 +668,16 @@ class BinanceClient: logger.info(f" 平仓模式: {reduce_only}") # 检查名义价值是否满足最小要求 - # 注意:对于平仓操作(reduce_only=True),币安允许更小的名义价值,所以放宽检查 - # 但为了安全,仍然检查一个更小的阈值(0.1 USDT) - min_notional_for_order = 0.1 if reduce_only else min_notional - - if notional_value < min_notional_for_order: + # 注意:对于平仓操作(reduce_only=True),完全跳过名义价值检查 + # 因为平仓是关闭现有持仓,币安允许任意大小的平仓订单(只要大于0) + if reduce_only: + logger.info(f" 平仓操作:跳过名义价值检查(名义价值: {notional_value:.2f} USDT)") + elif notional_value < min_notional: logger.warning( f"❌ {symbol} 订单名义价值不足: {notional_value:.2f} USDT < " - f"最小要求: {min_notional_for_order:.2f} USDT" + f"最小要求: {min_notional:.2f} USDT" ) - if reduce_only: - logger.warning(f" 这是平仓订单,但名义价值仍然太小,无法执行") - else: - logger.warning(f" 需要增加数量或提高仓位大小") + logger.warning(f" 需要增加数量或提高仓位大小") return None # 检查最小保证金要求(避免手续费侵蚀收益)