@vyacheslav_b Thank you very much for your support.

I would like to ask, if I want to filter out the crypto codes with the highest sharpness, what should I do? Thank you. I tried using the get_best_instruments function but it didn't work

import qnt.stats as qnstats
# data = qndata.stocks.load_ndx_data(tail = 17*365, dims = ("time", "field", "asset"))
data = qndata.stocks.load_ndx_data(min_date="2005-01-01")
def get_best_instruments(data, weights, top_size):
# compute statistics:
stats_per_asset = qnstats.calc_stat(data, weights, per_asset=True)
# calculate ranks of assets by "sharpe_ratio":
ranks = (-stats_per_asset.sel(field="sharpe_ratio")).rank("asset")
# select top assets by rank "top_period" days ago:
top_period = 1
rank = ranks.isel(time=-top_period)
top = rank.where(rank <= top_size).dropna("asset").asset
# select top stats:
top_stats = stats_per_asset.sel(asset=top.values)
# print results:
print("SR tail of the top assets:")
display(top_stats.sel(field="sharpe_ratio").to_pandas().tail())
print("avg SR = ", top_stats[-top_period:].sel(field="sharpe_ratio").mean("asset")[-1].item())
display(top_stats)
return top_stats.coords["asset"].values
get_best_instruments(data, weights, 10)

19ae499c-71f3-4702-bba3-81d20fb6c5ac-image.png