diff --git a/config/settings.py b/config/settings.py index f3d4eda..9608f89 100644 --- a/config/settings.py +++ b/config/settings.py @@ -31,7 +31,12 @@ class Settings(BaseSettings): # Monitoring LOG_LEVEL: str = "INFO" - # Profit filter + # Profit filter - 不同周期的最低盈利要求 + MIN_PROFIT_PCT_SHORT: float = 1.0 # 短周期 (5m/15m/1h) 最低 1% + MIN_PROFIT_PCT_MEDIUM: float = 2.0 # 中周期 (4h/1d) 最低 2% + MIN_PROFIT_PCT_LONG: float = 5.0 # 长周期 (1d/1w) 最低 5% + + # 向后兼容 MIN_PROFIT_PCT: float = 1.0 PREFER_INTRADAY: bool = True diff --git a/signals/llm_decision.py b/signals/llm_decision.py index a76e8a5..db7e78c 100644 --- a/signals/llm_decision.py +++ b/signals/llm_decision.py @@ -228,7 +228,7 @@ ${current_price:,.2f} **重要原则**: 1. **优先日内短线** - 重点关注 short_term_5m_15m_1h 的日内交易机会 -2. **盈利空间≥1%** - 只有预期盈利 ≥1% 时才给出操作建议,否则 exists=false +2. **不同周期盈利要求不同** - 短期≥1%,中期≥2%,长期≥5%,不满足则 exists=false 3. **自行识别支撑压力位** - 从K线数据中找出重要的高低点作为支撑压力位 4. **响应必须是有效的JSON格式** - 不要包含注释 @@ -316,13 +316,16 @@ ${current_price:,.2f} - 历史重要价格区间 - 大周期趋势线 -## 止盈止损设置 +## 止盈止损设置(不同周期要求不同) -- 短期: 止损 0.3%-0.5%, 止盈 ≥1% -- 中期: 止损 1%-2%, 止盈 ≥2% -- 长期: 止损 2%-4%, 止盈 ≥4% +- 短期 (5m/15m/1h): 止损 0.3%-0.5%, 止盈 ≥1% +- 中期 (4h/1d): 止损 1%-2%, 止盈 ≥2% +- 长期 (1d/1w): 止损 2%-4%, 止盈 ≥5% -只有当 (take_profit - entry) / entry ≥ 1% 时才给出具体建议! +重要:各周期的盈利空间必须满足最低要求才给出建议: +- 短期机会: (take_profit - entry) / entry ≥ 1% +- 中期机会: (take_profit - entry) / entry ≥ 2% +- 长期机会: (take_profit - entry) / entry ≥ 5% """ return prompt @@ -444,41 +447,43 @@ ${current_price:,.2f} medium_term = swing long_term = {} - # Apply minimum profit filter to all opportunities - MIN_PROFIT_PCT = settings.MIN_PROFIT_PCT + # Apply minimum profit filter to all opportunities - 不同周期不同要求 + MIN_PROFIT_SHORT = settings.MIN_PROFIT_PCT_SHORT # 短周期 1% + MIN_PROFIT_MEDIUM = settings.MIN_PROFIT_PCT_MEDIUM # 中周期 2% + MIN_PROFIT_LONG = settings.MIN_PROFIT_PCT_LONG # 长周期 5% - # Filter short_term - short_term_valid = meets_profit_threshold(short_term, MIN_PROFIT_PCT) + # Filter short_term (最低 1%) + short_term_valid = meets_profit_threshold(short_term, MIN_PROFIT_SHORT) if short_term.get('exists') and not short_term_valid: profit_pct = calc_profit_pct( safe_float(short_term.get('entry_price'), 0), safe_float(short_term.get('take_profit'), 0), short_term.get('direction') ) - logger.info(f"短期机会被过滤: 盈利空间 {profit_pct:.2f}% < {MIN_PROFIT_PCT}%") - short_term = {'exists': False, 'reasoning': f'盈利空间不足1% (仅{profit_pct:.2f}%),建议观望'} + logger.info(f"短期机会被过滤: 盈利空间 {profit_pct:.2f}% < {MIN_PROFIT_SHORT}%") + short_term = {'exists': False, 'reasoning': f'盈利空间不足{MIN_PROFIT_SHORT}% (仅{profit_pct:.2f}%),建议观望'} - # Filter medium_term - medium_term_valid = meets_profit_threshold(medium_term, MIN_PROFIT_PCT) + # Filter medium_term (最低 2%) + medium_term_valid = meets_profit_threshold(medium_term, MIN_PROFIT_MEDIUM) if medium_term.get('exists') and not medium_term_valid: profit_pct = calc_profit_pct( safe_float(medium_term.get('entry_price'), 0), safe_float(medium_term.get('take_profit'), 0), medium_term.get('direction') ) - logger.info(f"中期机会被过滤: 盈利空间 {profit_pct:.2f}% < {MIN_PROFIT_PCT}%") - medium_term = {'exists': False, 'reasoning': f'盈利空间不足1% (仅{profit_pct:.2f}%),建议观望'} + logger.info(f"中期机会被过滤: 盈利空间 {profit_pct:.2f}% < {MIN_PROFIT_MEDIUM}%") + medium_term = {'exists': False, 'reasoning': f'盈利空间不足{MIN_PROFIT_MEDIUM}% (仅{profit_pct:.2f}%),建议观望'} - # Filter long_term - long_term_valid = meets_profit_threshold(long_term, MIN_PROFIT_PCT) + # Filter long_term (最低 5%) + long_term_valid = meets_profit_threshold(long_term, MIN_PROFIT_LONG) if long_term.get('exists') and not long_term_valid: profit_pct = calc_profit_pct( safe_float(long_term.get('entry_price'), 0), safe_float(long_term.get('take_profit'), 0), long_term.get('direction') ) - logger.info(f"长期机会被过滤: 盈利空间 {profit_pct:.2f}% < {MIN_PROFIT_PCT}%") - long_term = {'exists': False, 'reasoning': f'盈利空间不足1% (仅{profit_pct:.2f}%),建议观望'} + logger.info(f"长期机会被过滤: 盈利空间 {profit_pct:.2f}% < {MIN_PROFIT_LONG}%") + long_term = {'exists': False, 'reasoning': f'盈利空间不足{MIN_PROFIT_LONG}% (仅{profit_pct:.2f}%),建议观望'} # Determine primary levels (priority: short > medium > long) - 优先日内短线 entry = market_context.get('current_price', 0)