{"record":{"id":"92393a48daec7bc6","repo":"microsoft/qlib","slug":"this-type-of-signal-is-not-supported","errorCode":null,"errorMessage":"This type of signal is not supported","messagePattern":"This type of signal is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/backtest/signal.py","lineNumber":105,"sourceCode":"\ndef create_signal_from(\n    obj: Union[Signal, Tuple[BaseModel, Dataset], List, Dict, Text, pd.Series, pd.DataFrame],\n) -> Signal:\n    \"\"\"\n    create signal from diverse information\n    This method will choose the right method to create a signal based on `obj`\n    Please refer to the code below.\n    \"\"\"\n    if isinstance(obj, Signal):\n        return obj\n    elif isinstance(obj, (tuple, list)):\n        return ModelSignal(*obj)\n    elif isinstance(obj, (dict, str)):\n        return init_instance_by_config(obj)\n    elif isinstance(obj, (pd.DataFrame, pd.Series)):\n        return SignalWCache(signal=obj)\n    else:\n        raise NotImplementedError(f\"This type of signal is not supported\")\n","sourceCodeStart":87,"sourceCodeEnd":106,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/signal.py#L87-L106","documentation":"create_signal_from in qlib/backtest/signal.py dispatches on the runtime type of its obj argument: Signal is returned as-is, tuple/list becomes ModelSignal(*obj), dict/str is treated as a config for init_instance_by_config, and pandas DataFrame/Series becomes SignalWCache. Any other type (int, None, numpy array, ndarray, torch tensor, etc.) falls into the else branch and raises NotImplementedError.","triggerScenarios":"Calling create_signal_from with a numpy.ndarray, torch.Tensor, None, or a bare object that is not one of the six supported container types; commonly happens when model.predict output is converted to .values or .to_numpy() before being passed in.","commonSituations":"Users convert predictions to numpy for serialization and forget to convert back to pandas; pass a path object (Path) instead of str; or pass a lambda/function as a signal source.","solutions":["Pass a pandas Series (typically named 'score') or DataFrame so SignalWCache is used.","If you have a config describing the signal class, pass the dict or its YAML string path.","If you have model+dataset, pass them as a tuple/list so ModelSignal is built.","Convert numpy arrays back: create_signal_from(pd.Series(arr, index=dates))."],"exampleFix":"# before\nsignal = create_signal_from(pred.values)  # ndarray -> NotImplementedError\n# after\nsignal = create_signal_from(pd.Series(pred.values, index=pred.index, name='score'))","handlingStrategy":"type-guard","validationCode":"import pandas as pd\nfrom qlib.backtest.signal import Signal\nSUPPORTED = (Signal, tuple, list, dict, str, pd.DataFrame, pd.Series)\nassert isinstance(obj, SUPPORTED), f'create_signal_from cannot handle {type(obj).__name__}'","typeGuard":"import pandas as pd\n\ndef is_signal_source(obj) -> bool:\n    return isinstance(obj, (tuple, list, dict, str, pd.DataFrame, pd.Series))","tryCatchPattern":"try:\n    sig = create_signal_from(obj)\nexcept NotImplementedError:\n    if isinstance(obj, pd.DataFrame):\n        obj = obj['score']\n    sig = create_signal_from(pd.Series(getattr(obj, 'values', obj)))","preventionTips":["Keep predictions as pandas objects end-to-end; avoid .values/.to_numpy() before signal creation.","Wrap third-party model outputs: convert to pd.Series with a proper DatetimeIndex first."],"tags":["qlib","signal","type-guard","dispatch"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}