{"record":{"id":"c92c25ccd51b2da5","repo":"microsoft/qlib","slug":"this-type-of-input-rtype-is-not-supported-c92c25","errorCode":null,"errorMessage":"This type of input {rtype} is not supported","messagePattern":"This type of input (.+?) is not supported","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/backtest/utils.py","lineNumber":163,"sourceCode":"\n        Returns\n        -------\n        Tuple[int, int]:\n        \"\"\"\n        # potential performance issue\n        assert self.level_infra is not None\n\n        day_start = pd.Timestamp(self.start_time.date())\n        day_end = epsilon_change(day_start + pd.Timedelta(days=1))\n        freq = self.level_infra.get(\"common_infra\").get(\"trade_exchange\").freq\n        _, _, day_start_idx, _ = Cal.locate_index(day_start, day_end, freq=freq)\n\n        if rtype == \"full\":\n            _, _, start_idx, end_index = Cal.locate_index(self.start_time, self.end_time, freq=freq)\n        elif rtype == \"step\":\n            _, _, start_idx, end_index = Cal.locate_index(*self.get_step_time(), freq=freq)\n        else:\n            raise ValueError(f\"This type of input {rtype} is not supported\")\n\n        return start_idx - day_start_idx, end_index - day_start_idx\n\n    def get_all_time(self) -> Tuple[pd.Timestamp, pd.Timestamp]:\n        \"\"\"Get the start_time and end_time for trading\"\"\"\n        return self.start_time, self.end_time\n\n    # helper functions\n    def get_range_idx(self, start_time: pd.Timestamp, end_time: pd.Timestamp) -> Tuple[int, int]:\n        \"\"\"\n        get the range index which involve start_time~end_time  (both sides are closed)\n\n        Parameters\n        ----------\n        start_time : pd.Timestamp\n        end_time : pd.Timestamp\n\n        Returns","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/utils.py#L145-L181","documentation":"In qlib/backtest/utils.py, the method that maps trading times to intraday indices (used by TradeCalendarManager for position-location bookkeeping) accepts rtype of only 'full' (whole trading range start_time~end_time) or 'step' (current step's time window). Any other rtype string raises ValueError before locate_index is called.","triggerScenarios":"Calling this internal helper (get_calendar_pos / index-location API of TradeCalendarManager) with rtype other than 'full' or 'step', e.g. 'day', 'range', or None.","commonSituations":"Custom strategies/executors subclass or call qlib's calendar utilities and invent a range type; refactor renames the literal ('total' vs 'full') and breaks the call.","solutions":["Pass rtype='full' for the whole trading period or rtype='step' for the current trading step.","If you need a custom window, call Cal.locate_index(start, end, freq=freq) directly with your own timestamps instead of extending rtype."],"exampleFix":"# before\nidx = cal_obj._get_start_end_index(rtype='day')\n# after\nidx = cal_obj._get_start_end_index(rtype='full')  # or 'step'","handlingStrategy":"validation","validationCode":"assert rtype in ('full', 'step'), f\"rtype must be 'full' or 'step', got {rtype!r}\"","typeGuard":"def is_valid_rtype(r) -> bool:\n    return r in ('full', 'step')","tryCatchPattern":null,"preventionTips":["Treat rtype as a closed enum in your code; define constants RTYPE_FULL='full', RTYPE_STEP='step'.","For custom time windows call Cal.locate_index directly instead of extending rtype."],"tags":["qlib","backtest","calendar","config"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}