{"record":{"id":"fe5b15fa1108e234","repo":"microsoft/qlib","slug":"can-t-find-a-freq-from-self-support-freq-that-ca","errorCode":null,"errorMessage":"can't find a freq from {self.support_freq} that can resample to {self.freq}!","messagePattern":"can't find a freq from (.+?) that can resample to (.+?)!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/data/storage/file_storage.py","lineNumber":101,"sourceCode":"\n    @property\n    def file_name(self) -> str:\n        return f\"{self._freq_file}_future.txt\" if self.future else f\"{self._freq_file}.txt\".lower()\n\n    @property\n    def _freq_file(self) -> str:\n        \"\"\"the freq to read from file\"\"\"\n        if not hasattr(self, \"_freq_file_cache\"):\n            freq = Freq(self.freq)\n            if freq not in self.support_freq:\n                # NOTE: uri\n                #   1. If `uri` does not exist\n                #       - Get the `min_uri` of the closest `freq` under the same \"directory\" as the `uri`\n                #       - Read data from `min_uri` and resample to `freq`\n\n                freq = Freq.get_recent_freq(freq, self.support_freq)\n                if freq is None:\n                    raise ValueError(f\"can't find a freq from {self.support_freq} that can resample to {self.freq}!\")\n            self._freq_file_cache = freq\n        return self._freq_file_cache\n\n    def _read_calendar(self) -> List[CalVT]:\n        # NOTE:\n        # if we want to accelerate partial reading calendar\n        # we can add parameters like `skip_rows: int = 0, n_rows: int = None` to the interface.\n        # Currently, it is not supported for the txt-based calendar\n\n        if not self.uri.exists():\n            self._write_calendar(values=[])\n\n        with self.uri.open(\"r\") as fp:\n            res = []\n            for line in fp.readlines():\n                line = line.strip()\n                if len(line) > 0:\n                    res.append(line)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/storage/file_storage.py#L83-L119","documentation":"Raised by FileCalendarStorage._freq_file (qlib/data/storage/file_storage.py) when the requested calendar freq is not directly available and no stored freq can serve as a resampling source. Qlib can resample calendars from a finer available freq (via Freq.get_recent_freq); if none of support_freq can be resampled into the target freq, this ValueError is raised. Typical when requesting a coarser or unrelated freq than everything on disk.","triggerScenarios":"Only a 'day' calendar exists on disk and you request freq='week' or 'month' without a finer source available for resampling logic; requesting '5min' when only 'day' exists (cannot upsample from coarse to fine); freq taxonomies that do not relate (e.g. 'tick' vs 'day').","commonSituations":"Asking qlib to derive weekly/monthly calendars without supplying the underlying daily/minute data; mismatched freq naming conventions between the request and dumped files; partial data downloads missing the fine-grained calendars.","solutions":["Request one of the freqs actually stored (check calendars/ folder stems) — resampling from a stored freq is only attempted, not guaranteed to succeed.","Provide a finer-grained calendar/calendar data on disk (e.g. dump 1min calendars) so the target freq can be resampled from it.","Verify freq strings use qlib's canonical units ('day', '1min', '5min', ...); unsupported spellings can never match or resample.","As a workaround, build week/month results yourself by resampling the daily loaded dataframe with pandas after fetching at 'day'."],"exampleFix":"# before\ncal = Cal.calendar(freq=\"week\")  # only calendars/day.txt on disk -> ValueError\n\n# after\ncal = Cal.calendar(freq=\"day\")\n# or dump a finer calendar (e.g. 1min) so 'week' can be resampled from it","handlingStrategy":"validation","validationCode":"from qlib.data.storage.file_storage import FileCalendarStorage\ntry:\n    FileCalendarStorage(freq, future).uri\n    ok = True\nexcept ValueError:\n    ok = False","typeGuard":null,"tryCatchPattern":"try:\n    cal = Cal.calendar(freq=freq)\nexcept ValueError as e:\n    if \"can't find a freq\" in str(e):\n        cal = Cal.calendar(freq=\"day\")  # fall back to stored freq, resample yourself\n    else:\n        raise","preventionTips":["Prefer requesting freqs that exist verbatim as calendar .txt files.","If you need week/month bars, fetch daily and resample with pandas in your pipeline."],"tags":["qlib","calendar","resample","frequency"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}