{"record":{"id":"f1ea3ac62d19f162","repo":"microsoft/qlib","slug":"interval-error-self-interval-f1ea3a","errorCode":null,"errorMessage":"interval error: {self.interval}","messagePattern":"interval error: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/data_collector/yahoo/collector.py","lineNumber":106,"sourceCode":"            start=start,\n            end=end,\n            interval=interval,\n            max_workers=max_workers,\n            max_collector_count=max_collector_count,\n            delay=delay,\n            check_data_length=check_data_length,\n            limit_nums=limit_nums,\n        )\n\n        self.init_datetime()\n\n    def init_datetime(self):\n        if self.interval == self.INTERVAL_1min:\n            self.start_datetime = max(self.start_datetime, self.DEFAULT_START_DATETIME_1MIN)\n        elif self.interval == self.INTERVAL_1d:\n            pass\n        else:\n            raise ValueError(f\"interval error: {self.interval}\")\n\n        self.start_datetime = self.convert_datetime(self.start_datetime, self._timezone)\n        self.end_datetime = self.convert_datetime(self.end_datetime, self._timezone)\n\n    @staticmethod\n    def convert_datetime(dt: [pd.Timestamp, datetime.date, str], timezone):\n        try:\n            dt = pd.Timestamp(dt, tz=timezone).timestamp()\n            dt = pd.Timestamp(dt, tz=tzlocal(), unit=\"s\")\n        except ValueError as e:\n            pass\n        return dt\n\n    @property\n    @abc.abstractmethod\n    def _timezone(self):\n        raise NotImplementedError(\"rewrite get_timezone\")\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/scripts/data_collector/yahoo/collector.py#L88-L124","documentation":"Raised by YahooCollector.init_datetime (scripts/data_collector/yahoo/collector.py:106) when self.interval is neither INTERVAL_1min nor INTERVAL_1d. Yahoo collection supports only daily and 1-minute bars; init_datetime runs during __init__, so an invalid interval aborts collector construction immediately. Note the earlier branch also clamps 1min start_datetime to DEFAULT_START_DATETIME_1MIN.","triggerScenarios":"Constructing any YahooCollector subclass with interval outside {INTERVAL_1min ('1min'), INTERVAL_1d ('1d')} — e.g. '5min', '60m', '1week', '1h'. The check happens before timezone conversion, so no request is ever made.","commonSituations":"Passing native Yahoo Finance interval vocabulary ('1m', '1h', '5m') instead of the collector's own constants; reusing a config from another collector; typos like '1 day'.","solutions":["Use interval='1d' or interval='1min' exactly when instantiating the collector / via --interval.","Reference the class constants (YahooCollector.INTERVAL_1d / INTERVAL_1min) rather than literals.","For other granularities, query yahooquery directly — this collector will not accept them."],"exampleFix":"# before\ncollector = YahooCollectorCN(..., interval='1h', ...)\n\n# after\ncollector = YahooCollectorCN(..., interval='1d', ...)","handlingStrategy":"validation","validationCode":"from scripts.data_collector.yahoo.collector import YahooCollector\nassert interval in (YahooCollector.INTERVAL_1d, YahooCollector.INTERVAL_1min), f'yahoo collector supports only 1d/1min, got {interval}'","typeGuard":"def is_yahoo_interval(interval: str) -> bool:\n    return interval in ('1d', '1min')","tryCatchPattern":"try:\n    collector = YahooCollectorCN(..., interval=interval)\nexcept ValueError as e:\n    if 'interval error' in str(e):\n        raise SystemExit(\"use interval '1d' or '1min'\")\n    raise","preventionTips":["Map Yahoo Finance native intervals ('1m') to the collector's vocabulary ('1min') at your CLI boundary.","Validate interval once at argument-parse time with a choices= flag."],"tags":["yahoo","interval","validation","collector"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}