问答交流

context.order_target 无法卖出股票

由mymdeep创建,最终由small_q 被浏览 10 用户

custom_print('info','卖出了'+str(ins))
        custom_print('info',context.portfolio.cash)
        result = context.order_target(context.symbol(ins), 0)
        custom_print('info','result='+str(result))
        custom_print('info',"holding="+str(context.get_account_positions()))
        custom_print('info',context.portfolio.cash)

我调用了这个卖出股票,发现有些时候,仍然无法卖出,第二天还持有,我是一个基金策略。部分日志如下:

评论
  • 首先, order_target是下单函数, 当天平仓单, 当天持仓量是不会减少的, 第二天(第二根k线)才会减少持仓量, 但是虽然会减少到0, 但依旧有仓位信息, 只不过它里面的可用仓位是0了, 要等到第三天(第三根k线)才会自持仓列表中彻底消失.