microsoft/qlib · error · ValueError

This type of input {rtype} is not supported

Error message

This type of input {rtype} is not supported

What it means

The day-relative range calculator only accepts rtype='full' (limitation across the whole trading day) or rtype='step' (limitation of the current step). Any other string hits the ValueError. This is a strict enum check on the rtype parameter of the decision's index-range API.

Source

Thrown at qlib/backtest/decision.py:504

            2) raise_error is True
        """
        # potential performance issue
        day_start = pd.Timestamp(self.start_time.date())
        day_end = epsilon_change(day_start + pd.Timedelta(days=1))
        freq = self.strategy.trade_exchange.freq
        _, _, day_start_idx, day_end_idx = Cal.locate_index(day_start, day_end, freq=freq)
        if self.trade_range is None:
            if raise_error:
                raise NotImplementedError(f"There is no trade_range in this case")
            else:
                return 0, day_end_idx - day_start_idx
        else:
            if rtype == "full":
                val_start, val_end = self.trade_range.clip_time_range(day_start, day_end)
            elif rtype == "step":
                val_start, val_end = self.trade_range.clip_time_range(self.start_time, self.end_time)
            else:
                raise ValueError(f"This type of input {rtype} is not supported")
            _, _, start_idx, end_index = Cal.locate_index(val_start, val_end, freq=freq)
            return start_idx - day_start_idx, end_index - day_start_idx

    def empty(self) -> bool:
        for obj in self.get_decision():
            if isinstance(obj, Order):
                # Zero amount order will be treated as empty
                if obj.amount > 1e-6:
                    return False
            else:
                return True
        return True

    def mod_inner_decision(self, inner_trade_decision: BaseTradeDecision) -> None:
        """
        This method will be called on the inner_trade_decision after it is generated.
        `inner_trade_decision` will be changed **inplace**.

View on GitHub (pinned to 79633dd950)

Solutions

  1. Use rtype='full' for the whole-day range or rtype='step' for the current step range
  2. If you need an unclipped range, omit trade_range handling and use raise_error=False to get the full day instead of inventing an rtype

Example fix

// before
idx = decision.get_range_limit(rtype='day', raise_error=True)
// after
idx = decision.get_range_limit(rtype='full', raise_error=False)
Defensive patterns

Strategy: validation

Validate before calling

rtype = rtype.lower()
assert rtype in ('full', 'step'), f"rtype must be 'full' or 'step', got {rtype!r}"
idx = decision.get_range_limit(rtype=rtype, raise_error=False)

Type guard

def is_valid_rtype(r: str) -> bool:
    return isinstance(r, str) and r in ('full', 'step')

Prevention

When it happens

Trigger: Calling the method with a typo or unsupported value, e.g. rtype='day', rtype='Step', or rtype=None while the decision has a trade_range set.

Common situations: Custom executor/strategy code passing a made-up rtype; case mismatch ('Full' vs 'full'); copying example code that predates the rtype parameter.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/d7b57d7f00b69aac. Report an issue: GitHub.