ValueError: instruments not exists for market <ticker> using my converted csv data into Qlib format
❓ Questions and Help
Hi,
I've converted my data for a particular US stock into Qlib format using command from doc python scripts/dump_bin.py dump_all --csv_path ~/.qlib/csv_data/my_data --qlib_dir ~/.qlib/qlib_data/my_data --include_fields open,close,high,low,volume,factor. Should a
I think this is causing an issue for me to run the "train mode" example you provided with my data because I get a ValueError: instruments not exists for market AAPL for example.
Thanks.
@AnonymousJY Hi, What is the format of the csv file and the "train model" config?
@AnonymousJY Hi, What is the format of the csv file and the "train model" config?
@zhupr Thanks for asking.
The format of the csv file is the following.
The frequency is daily.
The file name is AAPL.csv. After converting the csv file with columns [open, close, high, low, volume], the bin files are saved in ~/.qlib/qlib_data/my_data/features/aapl (e.g., close.day.bin).
The "train model" is the same as one in here. Basically, I tried to change the dataset but run the same workflow example you guys provided.
--Edit--
I think I know what I was doing incorrectly. When I convert a single stock csv file into Qlib format, only all.txt instrument is created. So for the "train model" parameter market and benchmark, I input all. Is this correct? Thanks.
@AnonymousJY Hi,
The market in config should be the stock list, which is the file in the instruments directory.
For example, D.features(["AAPL"], ["$close"]) is correct, D.features(D.instruments("AAPL"), ["$close"]) is wrong.
You can set the market in here to all to:market = "all" benchmarket = "AAPL", all is the data set used by train, benchmark is the benchmark for comparison of backtest results (single stock)
@AnonymousJY Hi,
The
marketin config should be the stock list, which is the file in theinstrumentsdirectory. For example,D.features(["AAPL"], ["$close"])is correct,D.features(D.instruments("AAPL"), ["$close"])is wrong. You can set themarketin here toallto:market = "all"benchmarket = "AAPL",allis the data set used by train,benchmarkis the benchmark for comparison of backtest results (single stock)
@zhupr Thanks.
After training my data, the output is the following, which I think is not working correctly.

The training code is the exact from this notebook. market=all and benchmarket=AAPL.
The all.txt file only has AAPL.
However, when I run with your given data in cn_data I can get similar results as yours.
Is this something you can point me to the right direction? Thanks.
@AnonymousJY I think you can set some break points (like import pdb; pdb.set_trace()) before fitting models and check the data.
@AnonymousJY I think you can set some break points (like
import pdb; pdb.set_trace()) before fitting models and check the data.
@you-n-g Thanks for the guidance. I think the problem is in the column label. After preparing data using .prepare, it returns label with same float numbers (see below screenshot).

However, I'm not sure why this is the case, because I don't see any issue with the features (see below).

Do you or anyone else might know why the same float numbers are generated? Thanks.
@AnonymousJY The dataset will use ZScoreNorm processor for label.
https://github.com/microsoft/qlib/blob/main/qlib/data/dataset/processor.py#L196 https://github.com/microsoft/qlib/blob/main/qlib/contrib/data/handler.py#L37
If you only contains 2 stocks. You will get values like you image after cross-sectional zscore normalization.
@AnonymousJY The dataset will use ZScoreNorm processor for label.
https://github.com/microsoft/qlib/blob/main/qlib/data/dataset/processor.py#L196 https://github.com/microsoft/qlib/blob/main/qlib/contrib/data/handler.py#L37
If you only contains 2 stocks. You will get values like you image after cross-sectional zscore normalization.
@you-n-g Thanks for the reply.
So for your working sample in "workflow_by_code.ipynb", the user would need to feed in multiple stock data like the example for the Chinese stocks in cn_data in order for that example model to train. Am I correct?
I was looking for single stock strategy. Thanks.
@AnonymousJY
Currently, the released strategy examples are for multi-instrument selection (it is the hotest problem in practical Quant research).
The trading for single asset get relative low priority.
The setting of single asset is similar to high-frequency trading https://github.com/microsoft/qlib/projects/2
We will consider releasing examples for single stock strategy in the future after we release high-frequency trading module.
@AnonymousJY Currently, the released strategy examples are for multi-instrument selection (it is the hotest problem in practical Quant research). The trading for single asset get relative low priority. The setting of single asset is similar to high-frequency trading https://github.com/microsoft/qlib/projects/2 We will consider releasing examples for single stock strategy in the future after we release high-frequency trading module.
@you-n-g Thanks for the reply. I look forward to that release. Closing this ticket.