This commit is contained in:
2026-06-24 17:22:24 +08:00
parent 5b1412eab0
commit fd5337f163
3 changed files with 50 additions and 3 deletions
+12
View File
@@ -128,6 +128,18 @@ def load_candidates(trade_date: date) -> DataContext:
PrintLog(LogLevel.INFO,
f'[validator] 候选: {len(candidates)} 通过, {len(excluded)} 排除')
# 3.5 补充:强制加入网格持仓股(不受价格过滤限制)
from core.sfgrid.model import SFGridTradeTarget
pos_rows = list(SFGridTradeTarget
.select(SFGridTradeTarget.stock_code)
.where(SFGridTradeTarget.enabled == True)
.dicts())
pos_codes = [r['stock_code'].split('.')[0] for r in pos_rows]
forced = [c for c in pos_codes if c not in candidates and c not in excluded]
if forced:
PrintLog(LogLevel.INFO, f'[validator] 强制加入网格持仓股: {forced}')
candidates.extend(forced)
# 4. 裁剪K线到只含候选股 (保留最近180日)
kline_df = kline_df[kline_df['stock_code'].isin(candidates)].copy()
cut_date = trade_date - timedelta(days=365)