microsoft/qlib · error · ValueError
interval error: {self.interval}
Error message
interval error: {self.interval} What it means
Raised by CryptoCollector.init_datetime when self.interval is neither INTERVAL_1min nor INTERVAL_1d. The collector supports exactly two intervals and clamps 1min start to DEFAULT_START_DATETIME_1MIN; anything else aborts construction.
Source
Thrown at scripts/data_collector/crypto/collector.py:112
start=start,
end=end,
interval=interval,
max_workers=max_workers,
max_collector_count=max_collector_count,
delay=delay,
check_data_length=check_data_length,
limit_nums=limit_nums,
)
self.init_datetime()
def init_datetime(self):
if self.interval == self.INTERVAL_1min:
self.start_datetime = max(self.start_datetime, self.DEFAULT_START_DATETIME_1MIN)
elif self.interval == self.INTERVAL_1d:
pass
else:
raise ValueError(f"interval error: {self.interval}")
self.start_datetime = self.convert_datetime(self.start_datetime, self._timezone)
self.end_datetime = self.convert_datetime(self.end_datetime, self._timezone)
@staticmethod
def convert_datetime(dt: [pd.Timestamp, datetime.date, str], timezone):
try:
dt = pd.Timestamp(dt, tz=timezone).timestamp()
dt = pd.Timestamp(dt, tz=tzlocal(), unit="s")
except ValueError as e:
pass
return dt
@property
@abc.abstractmethod
def _timezone(self):
raise NotImplementedError("rewrite get_timezone")
View on GitHub (pinned to 79633dd950)
Solutions
- Use --interval 1d or --interval 1min for the crypto collector.
- For sub-daily data other than 1min (e.g. 5min from binance), use the dedicated collector under scripts/data_collector/crypto/ that supports it, not this eastmoney-style path.
- Sanitize the CLI value (strip whitespace, lowercase) before passing.
Example fix
# before python collector.py download_data --interval 5min ... # after python collector.py download_data --interval 1min ...
Defensive patterns
Strategy: validation
Validate before calling
assert interval in ("1d", "1min"), f"crypto collector supports 1d/1min only, got {interval!r}" Prevention
- Whitelist interval values in the wrapper script invoking the collector.
- Use the binance-based crypto collector for other granularities.
When it happens
Trigger: Instantiating/running the crypto collector with --interval 5min, 15min, 1h, or a typo; interval value coming from a shared config that includes values valid for other collectors but not this one.
Common situations: Reusing the yahoo/collector interval vocabulary (which supports 5min etc.) with the crypto collector; shell quoting issues leaving whitespace in the interval string.
Related errors
- cannot support {interval}
- interval error: {self.interval}
- source_dir and target_dir cannot be None
- request error
- This type of input is not supported
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/5bef6b89e8f96638.
Report an issue: GitHub.