Navigation

    Quantiacs Community

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

    KeyError: "cannot represent labeled-based slice indexer for coordinate 'time' with a slice over integer positions; the index is unsorted or non-unique"

    Support
    2
    5
    220
    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.
    • N
      newbiequant96 last edited by

      Hello, I am currently using the following backtest to develop a strategy using neural network

      import qnt.data as qndata
      import qnt.stats as qnstats
      retrain_interval = 19*365 + 1
      data = qndata.stocks.load_ndx_data(min_date ="2005-01-01")
      
      models = train_model(data)
      weights = predict(models, data)
      is_liquid = data.sel(field="is_liquid")
      weights   = weights * is_liquid
      
      def get_enough_bid_for(data_, weights_):
          time_traded = weights_.time[abs(weights_).fillna(0).sum('asset') > 0]
          is_strategy_traded = len(time_traded)
          if is_strategy_traded:
              return xr.where(weights_.time < time_traded.min(), data_.sel(field="is_liquid"), weights_)
          return weights_
      
      
      weights = get_enough_bid_for(data, weights)
      weights = weights.fillna(0)
      # Calculate stats
      stats = qnstats.calc_stat(data, weights)
      display(stats.to_pandas().tail())
      
      # Graph
      performance = stats.to_pandas()["equity"]
      import qnt.graph as qngraph
      #qngraph.make_plot_filled(performance.index, performance, name="PnL (Equity)", type="log")
      

      The results of checking the strategy file are normal, however when I run precheck the following error occurs

      469fc971-7907-4a18-875b-71f8ba467669-image.png
      bf6144b2-1cd1-4ae4-8786-ce0ae4f36a72-image.png
      16bdea24-da19-4e24-a5ce-d2aae7480bbc-image.png
      10d2812d-f309-4140-8b03-945e1816b404-image.png

      And when I submit the strategy, it is put into the filter with the error that there is no weight. Please help me fix the error. Thank you.

      My strategy ID is 16900804

      @support @Vyacheslav_B

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

        Hi @newbiequant96,
        You need to need to, in the init notebook write: !pip install pandas==1.2.5
        I recently encountered that problem again, in my case I think, because statsmodels is not compatible with the default pandas version, it upgrades it.
        It needs to be downgraded again in my case.
        Hope this will work for you.
        Regards

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

          This post is deleted!
          M 1 Reply Last reply Reply Quote 0
          • M
            magenta.kabuto @newbiequant96 last edited by

            @newbiequant96 no problem.
            I think the issue now is unrelated to the the previous issue. If you can show what is written above return code 1, I can maybe help.
            It seems to be an issue in the code.
            Regards

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

              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