{"record":{"id":"28c37e7d3e57263b","repo":"microsoft/qlib","slug":"cannot-support-self-interval","errorCode":null,"errorMessage":"cannot support {self.interval}","messagePattern":"cannot support (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/data_collector/yahoo/collector.py","lineNumber":191,"sourceCode":"            try:\n                _result = _get_simple(start_datetime, end_datetime)\n            except ValueError as e:\n                pass\n        elif interval == self.INTERVAL_1min:\n            _res = []\n            _start = self.start_datetime\n            while _start < self.end_datetime:\n                _tmp_end = min(_start + pd.Timedelta(days=7), self.end_datetime)\n                try:\n                    _resp = _get_simple(_start, _tmp_end)\n                    _res.append(_resp)\n                except ValueError as e:\n                    pass\n                _start = _tmp_end\n            if _res:\n                _result = pd.concat(_res, sort=False).sort_values([\"symbol\", \"date\"])\n        else:\n            raise ValueError(f\"cannot support {self.interval}\")\n        return pd.DataFrame() if _result is None else _result\n\n    def collector_data(self):\n        \"\"\"collector data\"\"\"\n        super(YahooCollector, self).collector_data()\n        self.download_index_data()\n\n    @abc.abstractmethod\n    def download_index_data(self):\n        \"\"\"download index data\"\"\"\n        raise NotImplementedError(\"rewrite download_index_data\")\n\n\nclass YahooCollectorCN(YahooCollector, ABC):\n    def get_instrument_list(self):\n        logger.info(\"get HS stock symbols......\")\n        symbols = get_hs_stock_symbols()\n        logger.info(f\"get {len(symbols)} symbols.\")","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/scripts/data_collector/yahoo/collector.py#L173-L209","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'}."],"exampleFix":"# before\ncollector.interval = '1h'  # mutation after init\ndf = collector.get_data(...)\n\n# after\ncollector = type(collector)(..., interval='1d', ...)  # rebuild with valid interval\ndf = collector.get_data(...)","handlingStrategy":"validation","validationCode":"assert collector.interval in (collector.INTERVAL_1d, collector.INTERVAL_1min), f'interval mutated to unsupported value: {collector.interval}'","typeGuard":"def collector_interval_ok(collector) -> bool:\n    return collector.interval in (collector.INTERVAL_1d, collector.INTERVAL_1min)","tryCatchPattern":null,"preventionTips":["Never assign collector.interval after construction; rebuild the collector instead.","Ensure subclasses call super().__init__ so interval validation runs early."],"tags":["yahoo","interval","defensive-check","subclassing"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}