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/

    Convert 'lines' object into 'Panads Series' for talib Indicators functions Input

    Indicators/Strategies/Analyzers
    1
    1
    196
    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.
    • ayush-somani
      ayush-somani last edited by

      def next(self):
          self.lines.CDLDARKCLOUDCOVER[0] = talib.CDLDARKCLOUDCOVER(self.data.open, self.data.high, self.data.low, self.data.close, penetration=0.1)
      

      Error -
      File "/Users/ayushsomani/PycharmProjects/pythonProject/OHLCBackTesting.py", line 61, in next
      self.lines.CDLDARKCLOUDCOVER[0] = talib.CDLDARKCLOUDCOVER(self.data.open, self.data.high, self.data.low, self.data.close, penetration=0.1)
      File "/Users/ayushsomani/PycharmProjects/pythonProject/venv/lib/python3.8/site-packages/talib/init.py", line 27, in wrapper
      return func(*args, **kwargs)
      TypeError: Argument 'open' has incorrect type (expected numpy.ndarray, got LineBuffer)

      Approach 1 -
      I used the indexing but again an error is raised.

      def next(self):
          self.lines.CDLDARKCLOUDCOVER[0] = talib.CDLDARKCLOUDCOVER(self.data.open[0], self.data.high[0], self.data.low[0], self.data.close[0], penetration=0.1)
      

      File "/Users/ayushsomani/PycharmProjects/pythonProject/OHLCBackTesting.py", line 61, in next
      self.lines.CDLDARKCLOUDCOVER[0] = talib.CDLDARKCLOUDCOVER(self.data.open[0], self.data.high[0], self.data.low[0], self.data.close[0], penetration=0.1)
      File "/Users/ayushsomani/PycharmProjects/pythonProject/venv/lib/python3.8/site-packages/talib/init.py", line 27, in wrapper
      return func(*args, **kwargs)
      TypeError: Argument 'open' has incorrect type (expected numpy.ndarray, got float)

      Approach 2 -
      If I use these indicators using bt.talib, there is some issue in the timeperiod. IMO, the CDLDARKCLOUDCOVER just compares the current bar with the previous bar. When I use self.CDLDARKCLOUDCOVER = bt.talib.CDLDARKCLOUDCOVER(self.data.open, self.data.high, self.data.low, self.data.close, penetration=0.1), it is skipping first 11 bars data. I am not getting the behaviour of this Indicator (CDLDARKCLOUDCOVER).

      Screenshot 2020-10-02 at 1.01.16 PM.png

      SBIN.csv

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