microsoft/qlib · error · ValueError

indicator_analysis method {method} is not supported!

Error message

indicator_analysis method {method} is not supported!

What it means

indicator_analysis weights each trade-indicator row (ffr, pa) when aggregating. The method argument selects the weighting scheme from a fixed dict {'mean', 'amount_weighted', 'value_weighted'}; anything else fails membership check against weights_dict and raises.

Source

Thrown at qlib/contrib/evaluate.py:132

        - if method is 'mean', count the mean statistical value of each trade indicator
        - if method is 'amount_weighted', count the deal_amount weighted mean statistical value of each trade indicator
        - if method is 'value_weighted', count the value weighted mean statistical value of each trade indicator

        Note: statistics method of pos is always "mean"

    Returns
    -------
    pd.DataFrame
        statistical value of each trade indicators
    """
    weights_dict = {
        "mean": df["count"],
        "amount_weighted": df["deal_amount"].abs(),
        "value_weighted": df["value"].abs(),
    }
    if method not in weights_dict:
        raise ValueError(f"indicator_analysis method {method} is not supported!")

    # statistic pa/ffr indicator
    indicators_df = df[["ffr", "pa"]]
    weights = weights_dict.get(method)
    res = indicators_df.mul(weights, axis=0).sum() / weights.sum()

    # statistic pos
    weights = weights_dict.get("mean")
    res.loc["pos"] = df["pos"].mul(weights).sum() / weights.sum()
    res = res.to_frame("value")
    return res


# This is the API for compatibility for legacy code
def backtest_daily(
    start_time: Union[str, pd.Timestamp],
    end_time: Union[str, pd.Timestamp],
    strategy: Union[str, dict, BaseStrategy],

View on GitHub (pinned to 79633dd950)

Solutions

  1. Use one of the three supported methods: 'mean' (count-weighted), 'amount_weighted' (deal_amount-weighted), or 'value_weighted' (value-weighted).
  2. Check membership before calling: if method not in {'mean','amount_weighted','value_weighted'}: raise ValueError(...).
  3. If you need custom weights, compute indicators_df.mul(w).sum()/w.sum() yourself instead of calling this helper.

Example fix

// before
res = indicator_analysis(df, method="amount")

// after
res = indicator_analysis(df, method="amount_weighted")
Defensive patterns

Strategy: validation

Validate before calling

VALID = {"mean", "amount_weighted", "value_weighted"}
if method not in VALID:
    raise ValueError(f"method must be one of {VALID}, got {method!r}")
indicator_analysis(df, method=method)

Type guard

def is_indicator_method(method) -> bool:
    return method in {"mean", "amount_weighted", "value_weighted"}

Try / catch

try:
    res = indicator_analysis(df, method=method)
except ValueError as e:
    if "not supported" in str(e):
        res = indicator_analysis(df, method="mean")
    else:
        raise

Prevention

When it happens

Trigger: Calling qlib.contrib.evaluate.indicator_analysis(df, method=...) with a string not in {'mean', 'amount_weighted', 'value_weighted'}, or passing a weighting vector where a method name is expected.

Common situations: Typos like 'amount_weight' or 'valueweighted'; assuming a custom weighting key exists; passing the argument positionally in the wrong order so another value lands in method.

Related errors


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