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/

    bt.talib.CORREL not working properly

    General Discussion
    2
    2
    253
    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.
    • Y
      Yi Fang last edited by Yi Fang

      For the indicator bt.talib.CORREL, if I pass in two indicators with missing values in the middle, no correlation will be calculated after the first missing value, even the values are there afterward, as a demonstration(a and b are both line object, i only show them as array here):

      import numpy as np
      
      a = np.array([1,1,1,1     ,1,1,1,1,1])     #space on 4th element is for readability
      b = np.array([1,1,1,np.nan,1,1,1,1,1])
      
      print(bt.talib.CORREL(a,b,timepriod=3))
      >>  [nan,nan,1,nan,nan,nan,nan,nan,nan]
      

      The intended result should be:

      [nan,nan,1,nan,nan,nan,1,1,1]
      

      In my actual case, both a and b are about 300 days long, and the missing values is about 30 days long in the middle of one data, and I tried to calculate correlation for a 6 days window, not sure if this has to do with issue. All the value before missing ones are correct.

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        I don't understand what your expectations are.

        • The code is broken (redacted, extracted and broken)
        • It is an external function from an external library (have you tried directly with ta-lib ... no)

        I do truly believe you are posting in the wrong forum.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }