{"record":{"id":"37a231d6178f7985","repo":"nautechsystems/nautilus_trader","slug":"chart-renderer-must-be-callable-was-type-rendere","errorCode":null,"errorMessage":"Chart renderer must be callable, was {type(renderer)}","messagePattern":"Chart renderer must be callable, was (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/nautilus_trader/analysis/tearsheet.py","lineNumber":2464,"sourceCode":"        Display title for the subplot.\n    renderer : Callable\n        Function that adds traces to the figure. Signature:\n        renderer(fig, row, col, returns, stats_pnls, stats_returns, stats_general,\n        theme_config, benchmark_returns, benchmark_name, run_info, account_info, engine, **kwargs)\n\n    Raises\n    ------\n    ValueError\n        If name is empty or renderer is not callable.\n\n    \"\"\"\n    _require_not_none(name, \"name\")\n\n    if not name.strip():\n        raise ValueError(\"Chart name cannot be empty\")\n\n    if not callable(renderer):\n        raise ValueError(f\"Chart renderer must be callable, was {type(renderer)}\")\n\n    _TEARSHEET_CHART_SPECS[name] = {\n        \"type\": subplot_type,\n        \"title\": title,\n        \"renderer\": renderer,\n    }\n\n\ndef _calculate_grid_layout(\n    charts: list[TearsheetChart],\n    custom_layout: GridLayout | None = None,\n) -> tuple[int, int, list, list[str], list[float], float, float]:\n    \"\"\"\n    Calculate dynamic grid layout based on selected charts.\n\n    Parameters\n    ----------\n    charts : list[TearsheetChart]","sourceCodeStart":2446,"sourceCodeEnd":2482,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/python/nautilus_trader/analysis/tearsheet.py#L2446-L2482","documentation":"register_tearsheet_chart requires renderer to be a callable; a non-callable value (string, class instance without __call__, None already caught by _require_not_none) raises this ValueError naming the offending type.","triggerScenarios":"Passing a non-callable such as a string, dict, or a module instead of a function that renders the chart into a plotly figure.","commonSituations":"Misreading the API and passing a figure or config object instead of a render function; importing the wrong symbol so the variable holds a non-function value.","solutions":["Pass a function with signature compatible with the registered chart spec","If you have an object, wrap its method: renderer=lambda fig, ctx: obj.render(fig, ctx)","Print type(renderer) to confirm it is callable before registering"],"exampleFix":"// before\nregister_tearsheet_chart(name=\"equity\", subplot_type=\"xy\", title=\"Equity\", renderer=\"equity_curve\")  # ValueError\n// after\nregister_tearsheet_chart(name=\"equity\", subplot_type=\"xy\", title=\"Equity\", renderer=render_equity_curve)","handlingStrategy":"type-guard","validationCode":"if not callable(renderer):\n    raise TypeError(f\"renderer must be callable, got {type(renderer).__name__}\")","typeGuard":"def is_valid_renderer(renderer) -> bool:\n    return callable(renderer)","tryCatchPattern":"try:\n    register_tearsheet_chart(name=n, subplot_type=st, title=t, renderer=r)\nexcept ValueError as e:\n    if \"must be callable\" in str(e):\n        r = wrap_renderer(r)\n        register_tearsheet_chart(name=n, subplot_type=st, title=t, renderer=r)\n    else:\n        raise","preventionTips":["Pass a function, not a figure or string identifier","Verify with callable() when the renderer comes from dynamic lookup","Keep renderer signatures consistent with built-in chart renderers"],"tags":["python","validation","valueerror","callable"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}