本策略的核心是在沪深300股票池中选股,选择的股票都是市值比较大,业绩比较好的白马股,根据市场相对位置以及基本面因子来选择股票,每月调仓一次,总的手续费低,策略的容量比较大,比较适合资金量大的稳健投资者和上班族。
回测数据(2020.1.1-2025.7.10)如下:



*回测数据只作测试用,不代表未来实际收益
1、策略初始化配置
定义了持股数、股票池、市场位置、调仓函数等
g.buy_stock_count = 5 # 持股数
g.check_out_lists = [] # 股票池
g.market_temperature = "mid" # 市场位置
g.month = 0 # 记录月份
# 调仓函数
run_daily(context, my_trade, time='9:45')
2、盘前处理
(1)计算市场位置
市场位置监控,获取沪深300指数过去220个交易日的收盘价,计算市场的相对位置,如果在0.2以下就是底部区域,0.9以上就是顶部区域,最近60日最高涨幅超过20%就是相对温和上涨位置。
def Market_temperature(context):
index300 = get_history(220, frequency="1d", field="close", security_list="000300.SS").close.tolist()
market_height = (np.mean(index300[-5:]) - np.min(index300)) / (np.max(index300) - np.min(index300))
if market_height < 0.20:
g.market_temperature = "low"
elif market_height > 0.90:
g.market_temperature = "high"
elif np.max(index300[-60:]) / np.min(index300) > 1.20:
g.market_temperature = "mid"
(2)过滤科创北交、ST、停牌、当日涨停股票
all_stocks = get_index_stocks("000300.SS")
list = []
check_out_lists = []
final_list = filter_st_status(all_stocks)
final_list = filter_halt_status(final_list)
final_list = filter_deli_status(final_list)
for stock in final_list:
info = get_stock_info(stock)
if not (('ST' in info[stock]["stock_name"]) or
('*' in info[stock]["stock

最低0.47元/天 解锁文章
1566

被折叠的 条评论
为什么被折叠?



