VeighNa量化社区
你的开源社区量化交易平台
qly840118's Avatar
Member
离线
1 帖子
声望: 0

我对这段代码有点疑问:当 self.pos == 0 的时候执行下面代码,条件成立后马上 self.buy(bar.close_price,min(self.lots,self.max_lots)), 既然已经马上发单成交了,那这时候 self.pos 已经大于 0 了,那么 self.buy(bar.close_price,min(self.lots,self.max_lots))下面的语句是不是就没有执行到了?
代码如下:

        if self.pos == 0:
        if self.fast_ma_pre < self.slow_ma_pre and self.fast_ma > self.slow_ma:
            if bar.close_price > self.daily_ma and self.run_buy:
               self.buy(bar.close_price,min(self.lots,self.max_lots))
                self.highest = bar.close_price
                self.avg_buy_price = bar.close_price
                self.holding_days = 0
                print(bar.datetime, bar.close_price, "开多单","开仓手数:",min(self.lots,self.max_lots))
© 2015-2022 微信 18391752892
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】