Navigation

    Quantiacs Community

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

    WARNING: Strategy trades non-liquid assets.

    Support
    2
    3
    222
    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.
    • D
      darwinps last edited by

      Hi

      I am confused why the warning for trading non-liquid assets appears in the second scenario.

      First scenario (no warning):

      def strategy(data):
          close = spx_data.sel(field='close')
          rsi = qnt.ta.rsi(close, 14)
          rsi = qnt.ta.shift(rsi, periods=1)
          weights = xarray.where(rsi < 30, 1, 0) + xarray.where(rsi > 70, -1, 0)    
          return weights
      
      weights = strategy(spx_data)
      is_liquid = spx_data.sel(field='is_liquid')
      weights = weights * is_liquid
      weights = qnt.output.clean(weights, spx_data, 'stocks_nasdaq100')
      stats = qnt.stats.calc_stat(spx_data, weights)
      

      Second scenario (warning shows up):

      def strategy(data):
          close = spx_data.sel(field='close')
          rsi = qnt.ta.rsi(close, 14)
          rsi = qnt.ta.shift(rsi, periods=1)
          weights = xarray.where(rsi < 30, 1, 0) + xarray.where(rsi > 70, -1, 0)
          filter = qnt.filter.filter_volatility_rolling(weights=weights, data=data, rolling_window=60, top_assets=20, metric='std', ascending=True)
          weights = weights * filter
          return weights
      
      weights = strategy(spx_data)
      is_liquid = spx_data.sel(field='is_liquid')
      weights = weights * is_liquid
      weights = qnt.output.clean(weights, spx_data, 'stocks_nasdaq100')
      stats = qnt.stats.calc_stat(spx_data, weights)
      

      Since the 'is_liquid' is applied after the weights are calculated, shouldn't there be no warning?

      Thank you in advance

      regards

      support 1 Reply Last reply Reply Quote 0
      • support
        support @darwinps last edited by

        Dear @darwinps,

        The difference is that you call filter method in your code where you see this warning. When that method is called, it calculates stats internally at that point in time, so that's when you actually see the warning, since at that time, the liquidity filter hasn't been applied.

        The final stat calculation that you are doing in your code (after the liquidity filter) is not giving any warnings which is expected behavior.

        Best regards

        D 1 Reply Last reply Reply Quote 0
        • D
          darwinps @support last edited by

          Hi @support ,

          That makes perfect sense

          Thank so much

          regards

          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