microsoft/qlib · error · ValueError
Us calendar is not supported
Error message
Us calendar is not supported
What it means
Raised unconditionally by CollectorFutureCalendarUS.collector (scripts/data_collector/future_calendar_collector.py:91). The US future-calendar branch is an explicit TODO stub: run(qlib_dir, region='us') dispatches to this class and immediately raises ValueError because no US calendar source has been implemented. There is no runtime condition that avoids it — it is a hard not-implemented marker.
Source
Thrown at scripts/data_collector/future_calendar_collector.py:91
if lg.error_code != "0":
raise ValueError(f"login respond error_msg: {lg.error_msg}")
rs = bs.query_trade_dates(
start_date=self._format_datetime(self.start_date), end_date=self._format_datetime(self.end_date)
)
if rs.error_code != "0":
raise ValueError(f"query_trade_dates respond error_msg: {rs.error_msg}")
data_list = []
while (rs.error_code == "0") & rs.next():
data_list.append(rs.get_row_data())
calendar = pd.DataFrame(data_list, columns=rs.fields)
calendar["is_trading_day"] = calendar["is_trading_day"].astype(int)
return pd.to_datetime(calendar[calendar["is_trading_day"] == 1]["calendar_date"]).to_list()
class CollectorFutureCalendarUS(CollectorFutureCalendar):
def collector(self) -> Iterable[pd.Timestamp]:
# TODO: US future calendar
raise ValueError("Us calendar is not supported")
def run(qlib_dir: Union[str, Path], region: str = "cn", start_date: str = None, end_date: str = None):
"""Collect future calendar(day)
Parameters
----------
qlib_dir:
qlib data directory
region:
cn/CN or us/US
start_date
start date
end_date
end date
Examples
-------View on GitHub (pinned to 79633dd950)
Solutions
- Use region='cn' — only the CN collector is implemented.
- For US calendars, source trading dates elsewhere (e.g. exchange holiday lists or another data vendor) and append them to calendars/day_future.txt yourself via the write_calendar pattern.
- If you must extend the tool, subclass CollectorFutureCalendar and implement collector() for US before calling run().
Example fix
# before run(qlib_dir='~/.qlib/qlib_data/us_data', region='us') # raises immediately # after run(qlib_dir='~/.qlib/qlib_data/cn_data', region='cn')
Defensive patterns
Strategy: validation
Validate before calling
if region.lower() == 'us':
raise SystemExit('US future calendar collection is not implemented; only region=cn is supported') Prevention
- Gate automation to region='cn' for future_calendar_collector.
- Check for NotImplementedError/ValueError stubs before assuming cn/us parity in any collector.
When it happens
Trigger: Calling run(qlib_dir, region='us'|'US') in scripts/data_collector/future_calendar_collector.py, or instantiating and calling .collector() on CollectorFutureCalendarUS.
Common situations: Users assuming feature parity between cn/us regions because the CLI accepts region='us'; automated pipelines iterating over both regions hitting the stub.
Related errors
- nfs-common is not found, please install it by execute: sudo
- Mount failed: requires sudo or permission denied
- mount {provider_uri} on {mount_path} error! Command error
- Mount failed: {e.stderr}
- We can't find the project path
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/5959ef6b6b95c3c5.
Report an issue: GitHub.