microsoft/qlib · error · NotImplementedError
Implement this function to match your own cache mechanism
Error message
Implement this function to match your own cache mechanism
What it means
Error "Implement this function to match your own cache mechanism" thrown in microsoft/qlib.
Source
Thrown at qlib/data/cache.py:353
.. note:: Override the `_uri` and `_expression` method to create your own expression cache mechanism.
"""
def expression(self, instrument, field, start_time, end_time, freq):
"""Get expression data.
.. note:: Same interface as `expression` method in expression provider
"""
try:
return self._expression(instrument, field, start_time, end_time, freq)
except NotImplementedError:
return self.provider.expression(instrument, field, start_time, end_time, freq)
def _uri(self, instrument, field, start_time, end_time, freq):
"""Get expression cache file uri.
Override this method to define how to get expression cache file uri corresponding to users' own cache mechanism.
"""
raise NotImplementedError("Implement this function to match your own cache mechanism")
def _expression(self, instrument, field, start_time, end_time, freq):
"""Get expression data using cache.
Override this method to define how to get expression data corresponding to users' own cache mechanism.
"""
raise NotImplementedError("Implement this method if you want to use expression cache")
def update(self, cache_uri: Union[str, Path], freq: str = "day"):
"""Update expression cache to latest calendar.
Override this method to define how to update expression cache corresponding to users' own cache mechanism.
Parameters
----------
cache_uri : str or Path
the complete uri of expression cache file (include dir path).
freq : strView on GitHub (pinned to 79633dd950)
Solutions
- Implement the cache method in your subclass to match your own cache mechanism.
- Use a built-in cache backend (e.g. DiskExpressionCache/DiskDatasetCache) that already implements it.
When it happens
Trigger: This error is raised at qlib/data/cache.py:353 when the guard condition fails: "Implement this function to match your own cache mechanism". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/12e3d085aaddb53f.
Report an issue: GitHub.