Accessing both market and index data in strategy()
-
Hi, I'd like to access to access both market and index data in strategy(). Would the following code work? It worked locally but when submitted the "checking" progress does not move at all.
# load data data = qndata.stocks.load_ndx_data(min_date="2005-01-01") def strategy(data): # get index data index_name = 'NDX' index_data = qndata.index.load_data(assets=[index_name], min_date='2005-01-01', forward_order=True) index_data = xr.align(index_data.sel(asset=index_name), data.isel(field=0), join='right')[0] ndx_values = index_data.values
I also tried a
load_data
function where I load both datasets and useload_data=load_data
inqnbt.backtest()
, but it quickly leads to a memory leak. -
@buyers_are_back Hello.
Here is an example: example link.
You can view the list of available indexes here.
If you want to use the
load_data
function, take a look at this example. You can implement the index download by analogy: -
@vyacheslav_b Thank you! I'll have a look
-
@buyers_are_back Hello.
Here is a new example of stock prediction using index data.
I recommend using the single-pass version.
https://quantiacs.com/documentation/en/data/indexes.html