microsoft/qlib · error · ValueError
can't find a freq from {self.support_freq} that can resample
Error message
can't find a freq from {self.support_freq} that can resample to {self.freq}! What it means
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.
Source
Thrown at qlib/data/storage/file_storage.py:101
@property
def file_name(self) -> str:
return f"{self._freq_file}_future.txt" if self.future else f"{self._freq_file}.txt".lower()
@property
def _freq_file(self) -> str:
"""the freq to read from file"""
if not hasattr(self, "_freq_file_cache"):
freq = Freq(self.freq)
if freq not in self.support_freq:
# NOTE: uri
# 1. If `uri` does not exist
# - Get the `min_uri` of the closest `freq` under the same "directory" as the `uri`
# - Read data from `min_uri` and resample to `freq`
freq = Freq.get_recent_freq(freq, self.support_freq)
if freq is None:
raise ValueError(f"can't find a freq from {self.support_freq} that can resample to {self.freq}!")
self._freq_file_cache = freq
return self._freq_file_cache
def _read_calendar(self) -> List[CalVT]:
# NOTE:
# if we want to accelerate partial reading calendar
# we can add parameters like `skip_rows: int = 0, n_rows: int = None` to the interface.
# Currently, it is not supported for the txt-based calendar
if not self.uri.exists():
self._write_calendar(values=[])
with self.uri.open("r") as fp:
res = []
for line in fp.readlines():
line = line.strip()
if len(line) > 0:
res.append(line)View on GitHub (pinned to 79633dd950)
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'.
Example fix
# before cal = Cal.calendar(freq="week") # only calendars/day.txt on disk -> ValueError # after cal = Cal.calendar(freq="day") # or dump a finer calendar (e.g. 1min) so 'week' can be resampled from it
Defensive patterns
Strategy: validation
Validate before calling
from qlib.data.storage.file_storage import FileCalendarStorage
try:
FileCalendarStorage(freq, future).uri
ok = True
except ValueError:
ok = False Try / catch
try:
cal = Cal.calendar(freq=freq)
except ValueError as e:
if "can't find a freq" in str(e):
cal = Cal.calendar(freq="day") # fall back to stored freq, resample yourself
else:
raise Prevention
- 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.
When it happens
Trigger: 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').
Common situations: 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.
Related errors
- {freq} is not supported in NumpyQuote
- This type of input {rtype} is not supported
- {self.storage_name}: {self.provider_uri} does not contain da
- This type of input is not supported
- The segment is out of valid calendar
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/fe5b15fa1108e234.
Report an issue: GitHub.