WARNING: Strategy trades non-liquid assets.
-
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
-
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
-