Stocks strategy
-
Hi @support
I saw an example where we could load stock data. Not sure if it's current or legacy.
Anyway, I tried a simple stocks strategy just to continue learning the platform and got an error:ValueError: indexes along dimension 'time' are not equal
Here is the code, I tried to follow what you had suggested for another strategy (the pairs one):
import numpy as np import pandas as pd import qnt.data as qndata import qnt.backtester as qnbk import xarray as xr long_threshold = 600 short_threshold = 300 def load_data(period): data = qndata.stocks_load_data(tail=period) return data def single_pass_strategy(data): tclose = data.sel(field='close') yclose = data.sel(field='close').shift(time=1) tt = tclose.isel(time=-1) yt = yclose.isel(time=-1) uptoday = list(tt > yt).count(True) if uptoday > long_threshold: return xr.where(tt > yt, 1, 0) elif uptoday < short_threshold: return xr.where(tt < yt, -1, 0) else: return xr.where(tt,0,0) weights = qnbk.backtest( competition_type="stocks", load_data=load_data, lookback_period= 4*365, start_date= "2017-01-01", strategy=single_pass_strategy )
Do you mind taking a look and advise how I can get it to run?
Thanks again for all your help. -
@spancham it is nor current, nor legacy, it is a leftover of an experiment, we are adding new instruments in addition to futures and crypto and testing them, please be patient for stocks. The logic will not change respect to futures or cryptos. Just more instruments and some details (dividends and splits).
-
@support
How are you guys coming along with the Equity data?
Thanks.
Sheikh -
@sheikh Hi, when it comes to stocks and historical simulations, the biggest issue is dealing with survivorship bias. The stock universe must include also stocks which have been delisted and we need to define trading rules which allow for trading instruments which make sense at each point in time. This week we are announing a new contest which is preparing the ground for stocks.