{"record":{"id":"5bef6b89e8f96638","repo":"microsoft/qlib","slug":"interval-error-self-interval","errorCode":null,"errorMessage":"interval error: {self.interval}","messagePattern":"interval error: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/data_collector/crypto/collector.py","lineNumber":112,"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":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/scripts/data_collector/crypto/collector.py#L94-L130","documentation":"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.","triggerScenarios":"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.","commonSituations":"Reusing the yahoo/collector interval vocabulary (which supports 5min etc.) with the crypto collector; shell quoting issues leaving whitespace in the interval string.","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."],"exampleFix":"# before\npython collector.py download_data --interval 5min ...\n\n# after\npython collector.py download_data --interval 1min ...","handlingStrategy":"validation","validationCode":"assert interval in (\"1d\", \"1min\"), f\"crypto collector supports 1d/1min only, got {interval!r}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Whitelist interval values in the wrapper script invoking the collector.","Use the binance-based crypto collector for other granularities."],"tags":["qlib","data-collector","crypto","interval","argument-validation"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}