Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    How to fix this error

    Support
    4
    5
    599
    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.
    • C
      cyan.gloom last edited by

      Screenshot (18).png
      Screenshot (19).png

      Hello, I'm confused with this error

      Could you help me ?

      support 1 Reply Last reply Reply Quote 0
      • support
        support @cyan.gloom last edited by

        @cyan-gloom It looks like you are looking for cointegrated assets, select some particular value of the Hurst exponent and then building some strategy using pairs of the selected assets.

        It is a bit difficult to say where the problem comes from without knowing what is "train". Can you comment the try/except part, and simply check if the "comb" you create make sense? Maybe you create pairs where one asset has no data.

        1 Reply Last reply Reply Quote 0
        • A
          antinomy last edited by

          Asuming whatever train is has a similar structure as the usual stock data, I get the same error as you with:

          import itertools
          import qnt.data as qndata
          
          stocks = qndata.stocks_load_ndx_data(tail=100)
          
          for comb in itertools.combinations(stocks.asset, 2):
              print(stocks.sel(asset=[comb]))
          

          There are 2 things to consider:

          1. comb is a tuple and you can't use tuples as value for the asset argument. You are putting brackets around it, but that gives you a list with one element wich is a tuple, hence the error about setting an array element as a sequence. Using stocks.sel(asset=list(comb)) instead resolves this issue but then you'll get an index error which leads to the second point
          2. each element in comb is a DataArray and cannot be used as an index element to select from the data. You want the string values instead, for this you can iterate over asset.values for instance.

          My example works when the loop looks like this:

          for comb in itertools.combinations(stocks.asset.values, 2):
              print(stocks.sel(asset=list(comb)))
          
          C 1 Reply Last reply Reply Quote 1
          • C
            cyan.gloom @antinomy last edited by

            @antinomy
            Thanks for your advice !

            1 Reply Last reply Reply Quote 0
            • I
              illustrious.mallard Banned last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB | Contributors
              • Documentation
              • About
              • Career
              • My account
              • Privacy policy
              • Terms and Conditions
              • Cookies policy
              Home
              Copyright © 2014 - 2021 Quantiacs LLC.
              Powered by NodeBB | Contributors