Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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?

    bta-lib
    3
    11
    2776
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Quỳnh H Nguyễn
      Quỳnh H Nguyễn last edited by

      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!

      1 Reply Last reply Reply Quote 1
      • run-out
        run-out last edited by

        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.

        RunBacktest.com

        T 1 Reply Last reply Reply Quote 4
        • T
          tx_562 @run-out last edited by

          @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?

          1 Reply Last reply Reply Quote 0
          • run-out
            run-out last edited by

            Seperately I think.

            RunBacktest.com

            1 Reply Last reply Reply Quote 1
            • Quỳnh H Nguyễn
              Quỳnh H Nguyễn last edited by

              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!

              1 Reply Last reply Reply Quote 0
              • run-out
                run-out last edited by

                btalib is not meant to be used in backtrader as a replacement for the built in indicators. bta-lib takes in a dataframe and returns a signal.

                RunBacktest.com

                Quỳnh H Nguyễn 1 Reply Last reply Reply Quote 1
                • Quỳnh H Nguyễn
                  Quỳnh H Nguyễn @run-out last edited by

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

                  btalib is not meant to be used in backtrader as a replacement for the built in indicators. bta-lib takes in a dataframe and returns a signal.

                  Oh, I believe that the BackTrader's owner want to replace TA-Lib by btalib not only because pure python, but also easier to create customize indicators.

                  run-out 1 Reply Last reply Reply Quote 0
                  • run-out
                    run-out @Quỳnh H Nguyễn last edited by

                    @Quỳnh-H-Nguyễn I could be wrong of course, I'm only reading the docs. But the main docs make no mention or show no real integration into the backtrader engine. Please let us know if I've got that wrong. It's all very new.

                    RunBacktest.com

                    Quỳnh H Nguyễn 1 Reply Last reply Reply Quote 0
                    • Quỳnh H Nguyễn
                      Quỳnh H Nguyễn @run-out last edited by

                      @run-out The docs's examples show that btalib runs separately like your mention above. I think maybe in the future backtrader will change something (I think it is just a little change) to use btalib in great backtest framework.

                      From the docs:

                      YATALIB
                      Yet Another Technical Analysis LIBrary. That could well have been the name, and the simple reason to create this library, having "yet another". But neither ... nor.

                      The reasons:

                      • Having a library which is easy to use and re-use
                      • Offering a correct implementation of indicators
                      • Achieving a readable implementation of indicators
                      • Making it possible to quickly and easily develop new indicators

                      Sorry if I'm wrong because English is not my native speaking/understanding!

                      run-out 1 Reply Last reply Reply Quote 0
                      • run-out
                        run-out @Quỳnh H Nguyễn last edited by

                        @Quỳnh-H-Nguyễn This is still an awesome tool. And if you wanted to create a line preloading into cerebro, this would make it dead easy. Cheers

                        RunBacktest.com

                        Quỳnh H Nguyễn 1 Reply Last reply Reply Quote 1
                        • Quỳnh H Nguyễn
                          Quỳnh H Nguyễn @run-out last edited by

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

                          @Quỳnh-H-Nguyễn This is still an awesome tool. And if you wanted to create a line preloading into cerebro, this would make it dead easy. Cheers

                          yeah, I got some times and don't know the reason. However, it is simple for a rookie like me to begin!

                          1 Reply Last reply Reply Quote 1
                          • 1 / 1
                          • First post
                            Last post
                          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors