microsoft/qlib · error · ValueError
report_type should be one of pred_long, pred_long_short, pre
Error message
report_type should be one of pred_long, pred_long_short, pred_short, excess_return_without_cost, excess_return_with_cost and model
What it means
OptimizationConfig (qlib/contrib/tuner/config.py) validates the report_type field of the tuner YAML. Only six report types are accepted: pred_long, pred_long_short, pred_short, excess_return_without_cost, excess_return_with_cost, and model. Anything else raises ValueError at config load time.
Source
Thrown at qlib/contrib/tuner/config.py:70
self.tuner_class = config.get("tuner_class", "QLibTuner")
# Save the tuner experiment for further view
tuner_ex_config_path = os.path.join(self.tuner_ex_dir, "tuner_config.yaml")
with open(tuner_ex_config_path, "w") as fp:
yaml.dump(TUNER_CONFIG_MANAGER.config, fp)
class OptimizationConfig:
def __init__(self, config, TUNER_CONFIG_MANAGER):
self.report_type = config.get("report_type", "pred_long")
if self.report_type not in [
"pred_long",
"pred_long_short",
"pred_short",
"excess_return_without_cost",
"excess_return_with_cost",
"model",
]:
raise ValueError(
"report_type should be one of pred_long, pred_long_short, pred_short, excess_return_without_cost, excess_return_with_cost and model"
)
self.report_factor = config.get("report_factor", "information_ratio")
if self.report_factor not in [
"annualized_return",
"information_ratio",
"max_drawdown",
"mean",
"std",
"model_score",
"model_pearsonr",
]:
raise ValueError(
"report_factor should be one of annualized_return, information_ratio, max_drawdown, mean, std, model_pearsonr and model_score"
)
self.optim_type = config.get("optim_type", "max")View on GitHub (pinned to 79633dd950)
Solutions
- Set report_type to one of: pred_long, pred_long_short, pred_short, excess_return_without_cost, excess_return_with_cost, model
- Check spelling and case in optimization_criteria.report_type in your YAML
- Upgrade/downgrade qlib to the version whose tuner examples you are following if the accepted set differs
Example fix
# before (tuner_config.yaml) optimization_criteria: report_type: long # after optimization_criteria: report_type: pred_long
Defensive patterns
Strategy: validation
Validate before calling
VALID_REPORT_TYPES = {'pred_long', 'pred_long_short', 'pred_short', 'excess_return_without_cost', 'excess_return_with_cost', 'model'}
assert cfg['optimization_criteria']['report_type'] in VALID_REPORT_TYPES Type guard
def is_valid_report_type(rt: str) -> bool:
return rt in {'pred_long', 'pred_long_short', 'pred_short', 'excess_return_without_cost', 'excess_return_with_cost', 'model'} Prevention
- Schema-validate tuner YAMLs (report_type, report_factor, optim_type) before loading
- Keep values lowercase exactly as documented
When it happens
Trigger: A tuner YAML with optimization_criteria: report_type: long (or any unsupported/misspelled/case-different value) is loaded by TunerConfigManager; the error fires during OptimizationConfig construction.
Common situations: Hand-writing the tuner config and abbreviating the report type; version drift where older/newer qlib accepts a different set of report types; copy-pasting a report type from analysis-report code (e.g. 'report_long') that is not valid here.
Related errors
- Config path is invalid.
- report_factor should be one of annualized_return, informatio
- optim_type should be min, max or correlation
- Please give the search space of model.
- Please give the search space of strategy.
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/c140edeccd424e51.
Report an issue: GitHub.