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
+1 -1
View File
@@ -10,7 +10,7 @@ GRID_HIGH = 11 # 网格上限
GRID_STEP = 1 # 网格间距(整数格)
# ---- 候选股过滤 ----
FILTER_MIN_CLOSE = 8 # 最低收盘价
FILTER_MIN_CLOSE = 5 # 最低收盘价(覆盖网格策略持仓股)
FILTER_MAX_CLOSE = 13 # 最高收盘价
REQUIRE_DAYS = 120 # 最少交易日数
+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)