{"record":{"id":"7a95eaacf3638bb5","repo":"microsoft/qlib","slug":"freq-is-not-supported-in-numpyquote","errorCode":null,"errorMessage":"{freq} is not supported in NumpyQuote","messagePattern":"(.+?) is not supported in NumpyQuote","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/backtest/high_performance_ds.py","lineNumber":149,"sourceCode":"\n        Parameters\n        ----------\n        quote_df : pd.DataFrame\n            the init dataframe from qlib.\n        self.data : Dict(stock_id, IndexData.DataFrame)\n        \"\"\"\n        super().__init__(quote_df=quote_df, freq=freq)\n        quote_dict = {}\n        for stock_id, stock_val in quote_df.groupby(level=\"instrument\", group_keys=False):\n            quote_dict[stock_id] = idd.MultiData(stock_val.droplevel(level=\"instrument\"))\n            quote_dict[stock_id].sort_index()  # To support more flexible slicing, we must sort data first\n        self.data = quote_dict\n\n        n, unit = Freq.parse(freq)\n        if unit in Freq.SUPPORT_CAL_LIST:\n            self.freq = Freq.get_timedelta(1, unit)\n        else:\n            raise ValueError(f\"{freq} is not supported in NumpyQuote\")\n        self.region = region\n\n    def get_all_stock(self):\n        return self.data.keys()\n\n    @lru_cache(maxsize=512)\n    def get_data(self, stock_id, start_time, end_time, field, method=None):\n        # check stock id\n        if stock_id not in self.get_all_stock():\n            return None\n\n        # single data\n        # If it don't consider the classification of single data, it will consume a lot of time.\n        if is_single_value(start_time, end_time, self.freq, self.region):\n            # this is a very special case.\n            # skip aggregating function to speed-up the query calculation\n\n            # FIXME:","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/high_performance_ds.py#L131-L167","documentation":"NumpyQuote.__init__ parses the freq string with Freq.parse(freq) and only accepts units in Freq.SUPPORT_CAL_LIST, which is currently just minute and day (qlib/utils/time.py:119). Any other calendar unit (week, month, quarter, year, or unknown tokens) raises this ValueError at construction time. NumpyQuote can therefore only serve intraday-minute or daily quote data.","triggerScenarios":"NumpyQuote(quote_df, freq=\"week\"), freq=\"1month\", freq=\"15min\" is fine but freq=\"2h\"/freq=\"1tick\" is not; passing an exchange-level config freq (e.g. from an executor config like \"day\" vs \"30min\" mismatch) that isn't minute- or day-granular.","commonSituations":"Upgrading pipelines that previously used PandasQuote (which does not validate freq) to the faster NumpyQuote; configs ported from top-level workflow freq settings such as \"week\"; typos like \"days\" or \"minutel\" that Freq.parse cannot normalize.","solutions":["Resample your data to daily or minute granularity and use freq=\"day\" or freq=\"<n>min\" (e.g. \"1min\", \"5min\")","If you need week/month bars with the same interface, fall back to PandasQuote, which accepts any freq string","Pre-validate with Freq.parse(freq) and assert the unit is in Freq.SUPPORT_CAL_LIST before constructing NumpyQuote"],"exampleFix":"# before\nquote = NumpyQuote(quote_df, freq=\"week\")\n# after\nquote_df_day = quote_df.groupby([pd.Grouper(level=\"datetime\", freq=\"D\"), pd.Grouper(level=\"instrument\")]).last().dropna()\nquote = NumpyQuote(quote_df_day, freq=\"day\")","handlingStrategy":"validation","validationCode":"from qlib.utils.time import Freq\n_, unit = Freq.parse(freq)\nassert unit in Freq.SUPPORT_CAL_LIST, (\n    f\"NumpyQuote only supports {Freq.SUPPORT_CAL_LIST}; got {unit!r} from freq {freq!r}\")","typeGuard":"def numpyquote_supports(freq: str) -> bool:\n    from qlib.utils.time import Freq\n    try:\n        _, unit = Freq.parse(freq)\n    except Exception:\n        return False\n    return unit in Freq.SUPPORT_CAL_LIST  # currently ['minute', 'day']","tryCatchPattern":"try:\n    quote = NumpyQuote(quote_df, freq=freq)\nexcept ValueError as e:\n    if \"is not supported in NumpyQuote\" in str(e):\n        quote = PandasQuote(quote_df, freq=freq)  # documented fallback with wider freq support\n    else:\n        raise","preventionTips":["Check Freq.SUPPORT_CAL_LIST before choosing NumpyQuote","Resample data to day or minute granularity upstream","Keep executor/exchange freq config consistent with data granularity"],"tags":["python","qlib","frequency","validation","backtest"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}