nautechsystems/nautilus_trader · error · KeyError
No tearsheet chart registered under '{chart_name}'.{hint} Re
Error message
No tearsheet chart registered under '{chart_name}'.{hint} Register one with `register_tearsheet_chart`. Available: {available} What it means
Raised while _create_tearsheet_figure iterates TearsheetConfig.charts: a configured chart name is not in the _TEARSHEET_CHART_SPECS registry. The message includes up to 3 difflib 'did you mean' suggestions (cutoff 0.6) and the sorted list of registered names, so typos are usually self-evident. Custom chart names only exist after an explicit register_tearsheet_chart call in the same process.
Source
Thrown at python/nautilus_trader/analysis/tearsheet.py:1678
)
chart_idx = 0
for row in range(1, rows + 1):
for col in range(1, cols + 1):
if chart_idx >= len(config.charts):
break
chart = config.charts[chart_idx]
chart_idx += 1
chart_name = chart.name
if chart_name not in _TEARSHEET_CHART_SPECS:
available = ", ".join(sorted(_TEARSHEET_CHART_SPECS))
suggestions = get_close_matches(chart_name, _TEARSHEET_CHART_SPECS, n=3, cutoff=0.6)
hint = f" Did you mean: {', '.join(suggestions)}?" if suggestions else ""
raise KeyError(
f"No tearsheet chart registered under '{chart_name}'.{hint} "
f"Register one with `register_tearsheet_chart`. Available: {available}",
)
renderer = _TEARSHEET_CHART_SPECS[chart_name]["renderer"]
chart_kwargs = chart.kwargs()
renderer(
fig=fig,
row=row,
col=col,
returns=returns,
stats_pnls=stats_pnls,
stats_returns=stats_returns,
stats_general=stats_general,
theme_config=theme_config,
benchmark_returns=benchmark_returns,View on GitHub (pinned to a4b06ed870)
Solutions
- Read the 'Available:' list in the error and correct the chart name to a registered one
- If the suggestion hint names your intended chart, apply that exact spelling
- For custom charts, call register_tearsheet_chart(name, subplot_type, title, renderer) before create_tearsheet in the same process
- Print registered specs to audit names: python -c "from nautilus_trader.analysis.tearsheet import _TEARSHEET_CHART_SPECS; print(sorted(_TEARSHEET_CHART_SPECS))"
Example fix
# before config = TearsheetConfig(charts=[TearsheetChart(name='rolling_sharpe')]) # KeyError: No tearsheet chart registered under 'rolling_sharpe' ... Available: ..., rolling-sharpe, ... # after config = TearsheetConfig(charts=[TearsheetChart(name='rolling-sharpe')])
Defensive patterns
Strategy: validation
Validate before calling
from nautilus_trader.analysis.tearsheet import _TEARSHEET_CHART_SPECS
names = [c.name for c in config.charts]
unknown = [n for n in names if n not in _TEARSHEET_CHART_SPECS]
assert not unknown, f'Unknown chart names: {unknown}; registered: {sorted(_TEARSHEET_CHART_SPECS)}' Try / catch
try:
create_tearsheet(returns=result, config=config)
except KeyError as e:
# message contains suggestions + available names
raise ValueError(f'Bad chart config: {e}') from None Prevention
- Define chart names as module constants instead of inline strings
- Register all custom charts in one startup function called before any tearsheet generation
- Diff configured names against sorted(_TEARSHEET_CHART_SPECS) in config tests
When it happens
Trigger: Passing TearsheetConfig(charts=[TearsheetChart(name=...)]) with a misspelled built-in name (e.g. 'equtiy' instead of 'equity'), or referencing a custom chart that was never registered via register_tearsheet_chart before create_tearsheet runs; also copy-pasting a chart list from another process/version where additional charts had been registered.
Common situations: Typos in TearsheetChart names; disabling/selecting charts by string in a config file; reusing a saved TearsheetConfig from an older nautilus_trader version whose chart names changed; forgetting that registration is per-process and happens in a script that was not run.
Related errors
- Theme '{name}' not found.{suggestion_text} Available themes:
- Chart renderer must be callable, was {type(renderer)}
- Grid has {rows * cols} cells but {len(charts)} charts were c
- {name} must not be None
- Theme name cannot be empty
AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16).
Data as JSON: /api/errors/9ed092fac815db5f.
Report an issue: GitHub.