问一个比较傻的问题:
def sell(context):
# 基础信息
date = transform_date(context.previous_date, 'str')
current_data = get_current_data()
# 根据时间执行不同的卖出策略
if str(context.current_dt)[-8:] == '11:28:00':
for s in list(context.portfolio.positions):
if ((context.portfolio.positions[s].closeable_amount != 0) and (current_data[s].last_price < current_data[s].high_limit) and (current_data[s].last_price > context.portfolio.positions[s].avg_cost)):
order_target_value(s, 0)
print( '止盈卖出', [get_security_info(s, date).display_name, s])
print('———————————————————————————————————')
if str(context.current_dt)[-8:] == '14:50:00':
for s in list(context.portfolio.positions):
if ((context.portfolio.positions[s].closeable_amount != 0) and (current_data[s].last_price < current_data[s].high_limit)):
order_target_value(s, 0)
print( '止损卖出', [get_security_info(s, date).display_name, s])
print('———————————————————————————————————')
在14:50:00运行这个函数,那么运行到if str(context.current_dt)[-8:] == '14:50:00':是不是已经超过了14:50:00了,可能是14:50:01了,会不会后面的代码不去运行了?