How to fix this error
-
Hello, I'm confused with this error
Could you help me ?
-
@cyan-gloom It looks like you are looking for cointegrated assets, select some particular value of the Hurst exponent and then building some strategy using pairs of the selected assets.
It is a bit difficult to say where the problem comes from without knowing what is "train". Can you comment the try/except part, and simply check if the "comb" you create make sense? Maybe you create pairs where one asset has no data.
-
Asuming whatever train is has a similar structure as the usual stock data, I get the same error as you with:
import itertools import qnt.data as qndata stocks = qndata.stocks_load_ndx_data(tail=100) for comb in itertools.combinations(stocks.asset, 2): print(stocks.sel(asset=[comb]))
There are 2 things to consider:
- comb is a tuple and you can't use tuples as value for the asset argument. You are putting brackets around it, but that gives you a list with one element wich is a tuple, hence the error about setting an array element as a sequence. Using stocks.sel(asset=list(comb)) instead resolves this issue but then you'll get an index error which leads to the second point
- each element in comb is a DataArray and cannot be used as an index element to select from the data. You want the string values instead, for this you can iterate over asset.values for instance.
My example works when the loop looks like this:
for comb in itertools.combinations(stocks.asset.values, 2): print(stocks.sel(asset=list(comb)))
-
@antinomy
Thanks for your advice ! -
This post is deleted!