microsoft/qlib · error · NotImplementedError

Implement this method if you want to use expression cache

Error message

Implement this method if you want to use expression cache

What it means

Error "Implement this method if you want to use expression cache" thrown in microsoft/qlib.

Source

Thrown at qlib/data/cache.py:360

        """
        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 : str

        Returns
        -------
        int
            0(successful update)/ 1(no need to update)/ 2(update failure).
        """
        raise NotImplementedError("Implement this method if you want to make expression cache up to date")

View on GitHub (pinned to 79633dd950)

Solutions

  1. Implement the `update` method in your expression cache subclass to keep the cache up to date.
  2. Use the built-in DiskExpressionCache which implements this method.

When it happens

Trigger: This error is raised at qlib/data/cache.py:360 when the guard condition fails: "Implement this method if you want to use expression cache". 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/e6ded14ed2ee8873. Report an issue: GitHub.