microsoft/qlib · error · ValueError
cannot support {self.interval}
Error message
cannot support {self.interval} What it means
Raised by YahooCollector.get_data (scripts/data_collector/yahoo/collector.py:191) when self.interval is neither INTERVAL_1d nor INTERVAL_1min at fetch time. In the normal flow this is unreachable because init_datetime (error 595) already validated the interval during construction — reaching it means the interval attribute was mutated after init or a subclass bypassed the parent __init__/init_datetime.
Source
Thrown at scripts/data_collector/yahoo/collector.py:191
try:
_result = _get_simple(start_datetime, end_datetime)
except ValueError as e:
pass
elif interval == self.INTERVAL_1min:
_res = []
_start = self.start_datetime
while _start < self.end_datetime:
_tmp_end = min(_start + pd.Timedelta(days=7), self.end_datetime)
try:
_resp = _get_simple(_start, _tmp_end)
_res.append(_resp)
except ValueError as e:
pass
_start = _tmp_end
if _res:
_result = pd.concat(_res, sort=False).sort_values(["symbol", "date"])
else:
raise ValueError(f"cannot support {self.interval}")
return pd.DataFrame() if _result is None else _result
def collector_data(self):
"""collector data"""
super(YahooCollector, self).collector_data()
self.download_index_data()
@abc.abstractmethod
def download_index_data(self):
"""download index data"""
raise NotImplementedError("rewrite download_index_data")
class YahooCollectorCN(YahooCollector, ABC):
def get_instrument_list(self):
logger.info("get HS stock symbols......")
symbols = get_hs_stock_symbols()
logger.info(f"get {len(symbols)} symbols.")View on GitHub (pinned to 79633dd950)
Solutions
- Do not mutate collector.interval after construction — create a new collector with the desired interval.
- Ensure subclasses call super().__init__(...) so init_datetime validates the interval (error 595 fires early with a clearer stack).
- Keep interval within {'1d', '1min'}.
Example fix
# before collector.interval = '1h' # mutation after init df = collector.get_data(...) # after collector = type(collector)(..., interval='1d', ...) # rebuild with valid interval df = collector.get_data(...)
Defensive patterns
Strategy: validation
Validate before calling
assert collector.interval in (collector.INTERVAL_1d, collector.INTERVAL_1min), f'interval mutated to unsupported value: {collector.interval}' Type guard
def collector_interval_ok(collector) -> bool:
return collector.interval in (collector.INTERVAL_1d, collector.INTERVAL_1min) Prevention
- Never assign collector.interval after construction; rebuild the collector instead.
- Ensure subclasses call super().__init__ so interval validation runs early.
When it happens
Trigger: Assigning collector.interval = '1h' after construction and then calling get_data; a subclass overriding __init__ or init_datetime so the 595 check never ran; direct instantiation of a partially-initialized object.
Common situations: Custom subclasses or scripts that tweak interval for retries; refactors that skip super().__init__; usually indicates a programming bug in user code rather than a data condition.
Related errors
- interval error: {self.interval}
- Invalid mount path: {mount_path}!
- This type of input is not supported
- Implement reward calculation recipe in `reward()`.
- Seed iterator for training is not available.
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/28c37e7d3e57263b.
Report an issue: GitHub.