microsoft/qlib · error · ValueError
Invalid index range: {} {}
Error message
Invalid index range: {} {} What it means
Error "Invalid index range: {} {}" thrown in microsoft/qlib.
Source
Thrown at qlib/data/base.py:191
cur_pit:
it is designed for the point-in-time data.
period: int
This is used for query specific period.
The period is represented with int in Qlib. (e.g. 202001 may represent the first quarter in 2020)
Returns
----------
pd.Series
feature series: The index of the series is the calendar index
"""
from .cache import H # pylint: disable=C0415
# cache
cache_key = str(self), instrument, start_index, end_index, *args
if cache_key in H["f"]:
return H["f"][cache_key]
if start_index is not None and end_index is not None and start_index > end_index:
raise ValueError("Invalid index range: {} {}".format(start_index, end_index))
try:
series = self._load_internal(instrument, start_index, end_index, *args)
except Exception as e:
get_module_logger("data").debug(
f"Loading data error: instrument={instrument}, expression={str(self)}, "
f"start_index={start_index}, end_index={end_index}, args={args}. "
f"error info: {str(e)}"
)
raise
series.name = str(self)
H["f"][cache_key] = series
return series
@abc.abstractmethod
def _load_internal(self, instrument, start_index, end_index, *args) -> pd.Series:
raise NotImplementedError("This function must be implemented in your newly defined feature")
@abc.abstractmethodView on GitHub (pinned to 79633dd950)
Solutions
- Pass a valid index range (start, end) within the bounds of the data.
- Check that the start index is not greater than the end index and both are within range.
When it happens
Trigger: This error is raised at qlib/data/base.py:191 when the guard condition fails: "Invalid index range: {} {}". 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/7c87b24f366ced7f.
Report an issue: GitHub.