Navigation

    Quantiacs Community

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

    Cant load data locally

    Support
    2
    3
    272
    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.
    • M
      magenta.kabuto last edited by

      Hello Quantiacs community,
      after a break due to work I came back yesterday to the platform and am trying to load data locally but for some reason I get the following error: KeyError: "cannot represent labeled-based slice indexer for coordinate 'time' with a slice over integer positions; the index is unsorted or non-unique" (Previously I could load the data with the same formula I used : def load_data(period):
      return qndata.stocks.load_ndx_data(min_date = "2002-01-01", dims = ('time', 'field', 'asset'),forward_order=True,tail = 36518)
      data= load_data(365
      10)).
      This formula works online however, does anyone know why? Thx a lot
      Regards

      M 1 Reply Last reply Reply Quote 0
      • C
        captain.nidoran last edited by

        First of all, welcome back bro! with you over here Q20 is going to be even more challenging 😉

        I have tried your code locally (in Spyder from Anaconda):
        c3a455f7-1970-4e7c-9c55-fbd38cb012ab-image.png

        and it manages well the code as you can see, but let me point out a couple of things that I find strange 😕

        1. When you defined the function "load_data" you established a parameter called "period" but after that you are not doing nothing with it inside de definition. So you can supress it obtaining same result:
          4cc8687c-3b9b-4740-b9be-bed67c1cf214-image.png
          or much better, set the parameter as the "tail" of the data:
          e6fd370e-eb3f-41aa-a3e8-6e973d981497-image.png

        2. The second strange thing, is that you are trying to set de parameter "min_date" and "tail" at the same time, and once you set the "min_date" let say that the "tail" doesnt do anything, taking a look inside the function that loads data inside stocks.py you can check it:
          30c661cb-b525-45ca-902d-7695e752e050-image.png
          So let me suggest to drop the min_date (wich is set to None by default), like this:
          c113fad6-f379-44de-adad-e7bd52d72408-image.png
          ...notice that the function now will load exactly what you indicates in the parameter 🙂 (in my example i am loading 10 years of data)

        3. And the last thing is just warn you, that you are loading the "dims" as time/field/asset wich is different from the default order (field/time/asset), this can affect if you for example try to use this data with some of the provided templates by quantiacs, so be careful 😕

        I hope I've helped 🙂
        Regards.

        1 Reply Last reply Reply Quote 0
        • M
          magenta.kabuto @magenta.kabuto last edited by

          @magenta-kabuto thx a lot bro for your support and pointing out the mistakes👍 🙂
          I will try the revised code now.
          Good luck for the competition 👍

          1 Reply Last reply Reply Quote 1
          • 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