API reference
Classic technical analysis stock charts in Python, built on matplotlib.
The pages in this section are generated from the source docstrings by scripts/make-api-docs.py.
Modules
- mplchart.chart — the
Chartclass: plotting, panes, rendering - mplchart.primitives — drawing primitives: price renderers, indicator renderers, overlays, and layout controls
- mplchart.indicators — technical analysis indicators for the pandas pipeline, named
SMA,EMA, etc. - mplchart.expressions — polars expression factories, the polars-pipeline counterparts of the indicators
- mplchart.styles — chart styling: the runtime
Stylerand its spec forms
Conventions
pricesis a pandas or polars DataFrame with columnsopen,high,low,close,volume(lower case; useChart(normalize=True)to normalize other layouts)- Indicators and expressions use upper case names:
SMA,EMA,MACD - Existing columns in
pricesare plotted directly by name:chart.plot("sma-20"); calculate and store custom columns before creating the chart - An indicator or expression is evaluated from
pricesduring plotting and is plotted directly (auto-plotted) or bound to a renderer primitive:Line(SMA(50))or the equivalent operator formSMA(50) @ Line() - Renderer primitives are optional:
chart.plot("sma-50")andchart.plot(SMA(50))use default rendering; useLine,Area, orBarsto customize the display - Constructor and
@binding both defer calculation; pandas expressions (pd.col(...)/.as_expr()) require constructor binding - Indicators chain with the
|operator:EMA(20) | ROC(1)