{"record":{"id":"b7401c051a6e6ac6","repo":"microsoft/qlib","slug":"unknown-instrument-type-inst","errorCode":null,"errorMessage":"Unknown instrument type {inst}","messagePattern":"Unknown instrument type (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/data/data.py","lineNumber":304,"sourceCode":"        raise NotImplementedError(\"Subclass of InstrumentProvider must implement `list_instruments` method\")\n\n    def _uri(self, instruments, start_time=None, end_time=None, freq=\"day\", as_list=False):\n        return hash_args(instruments, start_time, end_time, freq, as_list)\n\n    # instruments type\n    LIST = \"LIST\"\n    DICT = \"DICT\"\n    CONF = \"CONF\"\n\n    @classmethod\n    def get_inst_type(cls, inst):\n        if \"market\" in inst:\n            return cls.CONF\n        if isinstance(inst, dict):\n            return cls.DICT\n        if isinstance(inst, (list, tuple, pd.Index, np.ndarray)):\n            return cls.LIST\n        raise ValueError(f\"Unknown instrument type {inst}\")\n\n\nclass FeatureProvider(abc.ABC):\n    \"\"\"Feature provider class\n\n    Provide feature data.\n    \"\"\"\n\n    @abc.abstractmethod\n    def feature(self, instrument, field, start_time, end_time, freq):\n        \"\"\"Get feature data.\n\n        Parameters\n        ----------\n        instrument : str\n            a certain instrument.\n        field : str\n            a certain field of feature.","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/data.py#L286-L322","documentation":"`InstrumentStorage.get_inst_type` (used by `D.list_instruments`) classifies the `instruments` argument: a dict containing key 'market' is a stockpool CONF, any other dict is a DICT of {instrument: datetime-range}, and list/tuple/pd.Index/np.ndarray is a LIST. Anything else — notably a bare string like 'csi300' — is rejected with this ValueError.","triggerScenarios":"Calling `D.list_instruments('csi300')` or passing an int/None/set as `instruments`. Strings are not accepted directly; they must be wrapped in a market config dict.","commonSituations":"Very common with new qlib users: `D.list_instruments(D.instruments('csi300'))` works but `D.list_instruments('csi300')` raises. Also triggered by passing `market='all'` string directly from a config file.","solutions":["Wrap the market string: `D.list_instruments({'market': 'csi300'})` or use `D.instruments('csi300')` which builds the dict for you.","For an explicit set of tickers, pass a list: `D.list_instruments(['SH600000', 'SZ000001'])`."],"exampleFix":"# before\ninsts = D.list_instruments('csi300')\n\n# after\ninsts = D.list_instruments({'market': 'csi300'})\n# or\ninsts = D.list_instruments(D.instruments('csi300'))","handlingStrategy":"type-guard","validationCode":"import pandas as pd, numpy as np\n\ndef valid_instruments(inst) -> bool:\n    return (\n        isinstance(inst, dict)\n        or isinstance(inst, (list, tuple, pd.Index, np.ndarray))\n    )","typeGuard":"import pandas as pd, numpy as np\nfrom typing import Union\n\ndef is_supported_instruments(inst) -> bool:\n    if isinstance(inst, dict):\n        return True  # market config or {inst: range} dict\n    return isinstance(inst, (list, tuple, pd.Index, np.ndarray))","tryCatchPattern":"try:\n    insts = D.list_instruments(instruments)\nexcept ValueError as e:\n    if 'Unknown instrument type' in str(e):\n        instruments = {'market': str(instruments)}\n        insts = D.list_instruments(instruments)\n    else:\n        raise","preventionTips":["Always build instruments via D.instruments('market_name') instead of raw strings.","In config files, keep the {'market': ...} dict shape."],"tags":["instruments","api-usage","validation"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}