For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Issue: AttributeError: 'LineBuffer' object has no attribute 'index'



  • Hey backtraders, I'm facing another issue..here are my codes and errors...Thank you so much!

    Codes:

    cerebro=bt.Cerebro()
    cerebro.broker.set_cash(10000.0)
    cerebro.adddata(data)
    class Double_ma(bt.Strategy):
      params=(('fast_ma',10),('slow_ma',60),)
      def __init__(self):
        self.opens=self.datas[0].open
        self.fast_ema=bta.ema(self.opens,period=self.params.fast_ma)
        self.slow_ema=bta.ema(self.opens,period=self.params.slow_ma)
        
      def next(self):
        if self.order:
          return
        if not self.postion:
          if self.fast_ema[-1]<slow_ema[-1] and fast_ema[0]>=slow_ema[0]:
            self.buy()
          else:
            self.fast_ema[-1]>slow_ema[-1] and fast_ema[0]<=slow_ema[0]
            self.sell()
    
    cerebro.addstrategy(Double_ma)
    cerebro.run()
    

    Result/error:

    AttributeError                            Traceback (most recent call last)
    <ipython-input-80-9cabffa96699> in <module>()
         21 
         22 cerebro.addstrategy(Double_ma)
    ---> 23 cerebro.run()
    
    8 frames
    /usr/local/lib/python3.6/dist-packages/btalib/meta/lines.py in __init__(self, line, *args, **kwargs)
        284                 self._minidx = pidx = p2 - 1  # beginning of result calculation
        285 
    --> 286                 trailprefix = pd.Series(np.nan, index=series.index[pidx:p2])
        287                 # Determine the actul seed value to use
        288                 if _seed == SEED_AVG:
    
    AttributeError: 'LineBuffer' object has no attribute 'index'
    


  • The script you posted can not be run. Please post the actual script that generates the error message.


Log in to reply
 

});