1. 满仓买进卖出的话,因为是次日的11:28 / 14:50卖,如果次日出现买入信号的话会买不进,如果纯做回测的话,可以半仓滚动。
2. 如果使用9:26分,信号会多很多。
# 买入
if len(context.portfolio.positions) == 0:
if len(stock_list)>0:
single_amount = context.portfolio.available_cash/2/len(stock_list) #空仓时,分仓一半买
for s in stock_list:
order_target_value(s, single_amount)
print( '买入', [get_security_info(s, date).display_name, s])
print('———————————————————————————————————')
else:
if len(stock_list)>0:
single_amount = context.portfolio.available_cash/len(stock_list) #有仓位时,大概率今天会卖出,用剩下的半仓去滚动
for s in stock_list:
order_target_value(s, single_amount)
print( '买入', [get_security_info(s, date).display_name, s])
print('———————————————————————————————————')
2024-03-26