{"record":{"id":"92577eee8e332565","repo":"hsliuping/TradingAgents-CN","slug":"name-92577e","errorCode":null,"errorMessage":"不支持的指标: {name}","messagePattern":"不支持的指标: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tradingagents/tools/analysis/indicators.py","lineNumber":246,"sourceCode":"        return out\n\n    if name == \"atr\":\n        _require_cols(df, [\"high\", \"low\", \"close\"])\n        n = int(params.get(\"n\", 14))\n        out[f\"atr{n}\"] = atr(df[\"high\"], df[\"low\"], df[\"close\"], n=n)\n        return out\n\n    if name == \"kdj\":\n        _require_cols(df, [\"high\", \"low\", \"close\"])\n        n = int(params.get(\"n\", 9))\n        m1 = int(params.get(\"m1\", 3))\n        m2 = int(params.get(\"m2\", 3))\n        kdj_df = kdj(df[\"high\"], df[\"low\"], df[\"close\"], n=n, m1=m1, m2=m2)\n        for c in kdj_df.columns:\n            out[c] = kdj_df[c]\n        return out\n\n    raise ValueError(f\"不支持的指标: {name}\")\n\n\ndef compute_many(df: pd.DataFrame, specs: List[IndicatorSpec]) -> pd.DataFrame:\n    if not specs:\n        return df.copy()\n    # 粗略去重（按 name+sorted(params)）\n    def key(s: IndicatorSpec):\n        p = s.params or {}\n        items = tuple(sorted(p.items()))\n        return (s.name.lower(), items)\n\n    unique_specs: List[IndicatorSpec] = []\n    seen = set()\n    for s in specs:\n        k = key(s)\n        if k not in seen:\n            seen.add(k)\n            unique_specs.append(s)","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/hsliuping/TradingAgents-CN/blob/74783e8817d6cf6de29867880631cc555153f36b/tradingagents/tools/analysis/indicators.py#L228-L264","documentation":"compute_indicator dispatches on the indicator name against the SUPPORTED set {'ma','ema','macd','rsi','boll','atr','kdj'}. An unrecognized name falls through all branches to this ValueError listing nothing but the name, so the caller can correct the spec. It is the single entry point also used by compute_many, so bad specs in batch lists surface here too.","triggerScenarios":"Calling compute_indicator(df, 'stoch') or compute_indicator(df, 'cci'); passing a typo like 'macd2', 'MA' (if case-sensitive), or 'bollinger'; or a compute_many spec list containing an unsupported name.","commonSituations":"Porting indicator lists from other TA libraries (TA-Lib names like 'STOCH', 'CCI', 'WILLR'); assuming a longer indicator menu than the 7 supported ones; case/format mismatches between config-driven indicator lists and SUPPORTED.","solutions":["Check the SUPPORTED constant at the top of indicators.py and use one of: ma, ema, macd, rsi, boll, atr, kdj.","Validate spec names against indicators.SUPPORTED before calling compute_many with config-driven lists.","Compute unsupported indicators separately with custom pandas/TA-Lib code and merge the resulting columns."],"exampleFix":"# before\nout = compute_indicator(df, \"bollinger\", n=20)\n\n# after\nfrom tradingagents.tools.analysis.indicators import SUPPORTED\nname = \"bollinger\" if \"bollinger\" in SUPPORTED else \"boll\"\nout = compute_indicator(df, name, n=20)","handlingStrategy":"validation","validationCode":"from tradingagents.tools.analysis.indicators import SUPPORTED\nname = name.strip().lower()\nif name not in SUPPORTED:\n    raise ConfigError(f\"indicator {name!r} not supported; choose from {sorted(SUPPORTED)}\")\nout = compute_indicator(df, name, **params)","typeGuard":"from tradingagents.tools.analysis.indicators import SUPPORTED\n\ndef is_supported_indicator(name: str) -> bool:\n    \"\"\"Type guard against the library's SUPPORTED indicator set.\"\"\"\n    return isinstance(name, str) and name in SUPPORTED","tryCatchPattern":"try:\n    out = compute_indicator(df, name, **params)\nexcept ValueError as e:\n    if \"不支持的指标\" in str(e):\n        log.warning(\"skipping unsupported indicator %s\", name)\n        out = df.copy()\n    else:\n        raise","preventionTips":["Validate config-driven indicator lists against indicators.SUPPORTED at config load time.","Compute exotic indicators (stoch, cci, willr) with TA-Lib/pandas separately and merge columns.","Fail fast on unknown names in batch specs before calling compute_many."],"tags":["indicators","dispatch","unsupported-operation","validation"],"backgroundTag":"unsupported-operation","analyzedSha":"74783e8817d6cf6de29867880631cc555153f36b","analyzedAt":"2026-08-28T11:39:07.729Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}