{"record":{"id":"d7e36eaa0c9c0e18","repo":"microsoft/qlib","slug":"no-file-is-found","errorCode":null,"errorMessage":"No file is found.","messagePattern":"No file is found\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"qlib/data/data.py","lineNumber":785,"sourceCode":"        # {For acceleration\n        # start_index, end_index, cur_index = kwargs[\"info\"]\n        # if cur_index == start_index:\n        #     if not hasattr(self, \"all_fields\"):\n        #         self.all_fields = []\n        #     self.all_fields.append(field)\n        #     if not hasattr(self, \"period_index\"):\n        #         self.period_index = {}\n        #     if field not in self.period_index:\n        #         self.period_index[field] = {}\n        # For acceleration}\n\n        if not field.endswith(\"_q\") and not field.endswith(\"_a\"):\n            raise ValueError(\"period field must ends with '_q' or '_a'\")\n        quarterly = field.endswith(\"_q\")\n        index_path = C.dpm.get_data_uri() / \"financial\" / instrument.lower() / f\"{field}.index\"\n        data_path = C.dpm.get_data_uri() / \"financial\" / instrument.lower() / f\"{field}.data\"\n        if not (index_path.exists() and data_path.exists()):\n            raise FileNotFoundError(\"No file is found.\")\n        # NOTE: The most significant performance loss is here.\n        # Does the acceleration that makes the program complicated really matters?\n        # - It makes parameters of the interface complicate\n        # - It does not performance in the optimal way (places all the pieces together, we may achieve higher performance)\n        #    - If we design it carefully, we can go through for only once to get the historical evolution of the data.\n        # So I decide to deprecated previous implementation and keep the logic of the program simple\n        # Instead, I'll add a cache for the index file.\n        data = np.fromfile(data_path, dtype=DATA_RECORDS)\n\n        # find all revision periods before `cur_time`\n        cur_time_int = int(cur_time.year) * 10000 + int(cur_time.month) * 100 + int(cur_time.day)\n        loc = np.searchsorted(data[\"date\"], cur_time_int, side=\"right\")\n        if loc <= 0:\n            return pd.Series(dtype=C.pit_record_type[\"value\"])\n        last_period = data[\"period\"][:loc].max()  # return the latest quarter\n        first_period = data[\"period\"][:loc].min()\n        period_list = get_period_list(first_period, last_period, quarterly)\n        if period is not None:","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/data.py#L767-L803","documentation":"`LocalPITProvider.period_feature` looks for `<provider_uri>/financial/<instrument>/<field>.index` and `.data` files. If either binary file is missing, it raises FileNotFoundError — the requested PIT field simply is not on disk for that instrument.","triggerScenarios":"Requesting `P($$roewa_q)` when the qlib data directory contains no financial/ subfolder (price-only data was dumped), or the field exists for some instruments but not the requested one (e.g. a delisted or new stock).","commonSituations":"Using `qlib.init(provider_uri=...)` with data from `dump_bin.py` on prices only (no `--data_type financial` / get_and_dump_financial_data step); pointing provider_uri at a different machine's data dir; case mismatches because the path is lowercased.","solutions":["Dump PIT data: use scripts/data_collector/utils/dump_bin.py with financial data (collector `get_and_dump_financial_data`), which writes financial/<inst>/<field>.{index,data}.","Verify the path exists: `ls $(python -c 'import qlib;from qlib.config import C;print(C.dpm.get_data_uri())')/financial/<inst>/` and confirm the field files.","If only some instruments lack the field, restrict instruments to those with the file."],"exampleFix":"# before\nqlib.init(provider_uri='./data/qlib_data')  # only day bins dumped\nD.features(insts, ['P($$roewa_q)'])\n\n# after\n# dump financial PIT data first\n# python dump_bin.py --data_type financial ... (or collector flow)\nqlib.init(provider_uri='./data/qlib_data_with_financial')\nD.features(insts, ['P($$roewa_q)'])","handlingStrategy":"validation","validationCode":"from qlib.config import C\nimport os\n\ndef pit_data_exists(instrument: str, field: str) -> bool:\n    base = C.dpm.get_data_uri() / 'financial' / instrument.lower()\n    return (base / f'{field}.index').exists() and (base / f'{field}.data').exists()","typeGuard":"import os\nfrom pathlib import Path\n\ndef pit_files_present(base_dir: Path, inst: str, field: str) -> bool:\n    d = base_dir / 'financial' / inst.lower()\n    return (d / f'{field}.index').is_file() and (d / f'{field}.data').is_file()","tryCatchPattern":"try:\n    df = D.features(insts, [f'P({field})'])\nexcept FileNotFoundError:\n    # PIT data absent for this field/instrument: skip or use fallback fields\n    df = D.features(insts, ['$close'])","preventionTips":["Dump financial data together with price data (collector + dump_bin).","Check provider_uri points at a dir containing financial/ before using $$ fields.","Note instrument names are lowercased in the financial path layout."],"tags":["pit-data","data-missing","filesystem"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}