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

What are different between bta-lib, ta-lib and internal BackTrader indicators?



  • Hello,

    Could anyone talk about different between them? I take a look around the sample of talib integration sample, and see that the internal indicators of BackTrader and ta-lib almost the same.

    Now BackTrader introduce the new one: bta-lib. And if the different are clarify for purposes and use cases are better. If this rookie's question is annoyed, please delete it!

    Thank you!



  • ta-lib is the python wrapper for the well established Technical Analysis Library external to backtrader.

    Backtrader makes use of this library with it's own connection to the ta-lib. These indicators are also call TA-Lib in backtrader, hence more confusion. You will need ta-lib python wrapper installed to use this.

    The last library is the very newly minted bta-lib. This was created by the maker of backtrader as a handy library for doing technical analysis when using pandas dataframes. In a nutshell, you can put in a OHLCV dataframe and BTA-LIB will spit out the indicator. It works quite well and is easier to use that the original ta-lib library.



  • @run-out said in What are different between bta-lib, ta-lib and internal BackTrader indicators?:

    The last library is the very newly minted bta-lib. This was created by the maker of backtrader as a handy library for doing technical analysis when using pandas dataframes. In a nutshell, you can put in a OHLCV dataframe and BTA-LIB will spit out the indicator. It works quite well and is easier to use that the original ta-lib library.

    Does bta-lib interact with the backtrader framework? Or is it meant to be used seprately?



  • Seperately I think.



  • I tried with btalib to compare with original TA-Lib

    class BTALIBBeginningStrategy(bt.Strategy):
        params = (
            ('MA', 100),
        )
    
        def __init__(self):
            #self.ma = bt.indicators.MovingAverageSimple(period=self.params.MA)
            self.ma = btalib.sma(self.data.close, period=self.p.MA)
    
    

    but I got this error

      File "/home/learner/venv/lib/python3.8/site-packages/btalib/indicator.py", line 152, in __call__
        b_init(self, *args, **kwargs)
      File "/home/learner/venv/lib/python3.8/site-packages/btalib/indicators/sma.py", line 28, in __init__
        self.o.sma = self.i0.rolling(window=self.p.period).mean()
      File "/home/learner/venv/lib/python3.8/site-packages/btalib/meta/lines.py", line 394, in real_multifunc_op
        return _MultiFunc_Op(self, *args, **kwargs)
      File "/home/learner/venv/lib/python3.8/site-packages/btalib/meta/lines.py", line 306, in __init__
        trailer = series[self._minidx:]
      File "/home/learner/venv/lib/python3.8/site-packages/backtrader/linebuffer.py", line 163, in __getitem__
        return self.array[self.idx + ago]
    TypeError: unsupported operand type(s) for +: 'int' and 'slice'
    

    The code with original TA-Lib runs normally. But I don't understand what the error with btalib. Please explain for new rookies!

    Thank you!


Log in to reply
 

});