From 5030cbcc9816b0d4107444690a83c968d864edd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Thu, 15 Jan 2026 21:27:38 +0800 Subject: [PATCH] a --- trading_system/config.py | 1 + trading_system/trade_recommender.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/trading_system/config.py b/trading_system/config.py index d3da953..593304a 100644 --- a/trading_system/config.py +++ b/trading_system/config.py @@ -202,6 +202,7 @@ defaults = { 'PRIMARY_INTERVAL': '1h', 'CONFIRM_INTERVAL': '4h', 'ENTRY_INTERVAL': '15m', + 'LIMIT_ORDER_OFFSET_PCT': 0.5, # 限价单偏移百分比(默认0.5%) } for key, value in defaults.items(): if key not in TRADING_CONFIG: diff --git a/trading_system/trade_recommender.py b/trading_system/trade_recommender.py index 46d49b1..a4d714d 100644 --- a/trading_system/trade_recommender.py +++ b/trading_system/trade_recommender.py @@ -282,6 +282,15 @@ class TradeRecommender: position_multiplier = min(1.0 + (signal_strength - 5) * 0.1, 1.5) suggested_position_pct = base_position_pct * position_multiplier + # 计算建议的挂单价(使用限价单,而不是市价单) + # 对于做多:建议价格略低于当前价格(当前价格的99.5%),以便在回调时买入 + # 对于做空:建议价格略高于当前价格(当前价格的100.5%),以便在反弹时卖出 + limit_price_offset_pct = config.TRADING_CONFIG.get('LIMIT_ORDER_OFFSET_PCT', 0.5) # 默认0.5% + if direction == 'BUY': + suggested_limit_price = current_price * (1 - limit_price_offset_pct / 100) + else: # SELL + suggested_limit_price = current_price * (1 + limit_price_offset_pct / 100) + # 准备推荐数据 recommendation_data = { 'symbol': symbol, @@ -307,7 +316,9 @@ class TradeRecommender: 'suggested_position_percent': suggested_position_pct, 'suggested_leverage': config.TRADING_CONFIG.get('LEVERAGE', 10), 'volume_24h': symbol_info.get('volume24h'), - 'volatility': symbol_info.get('volatility') + 'volatility': symbol_info.get('volatility'), + 'order_type': 'LIMIT', # 使用限价单 + 'suggested_limit_price': suggested_limit_price # 建议的挂单价 } # 不再自动保存到数据库,只返回推荐数据