finance plots¶
Matplotlib plots and performance tables for financial return series, price paths, and technical-indicator panels.
Overview¶
finance-plots is the presentation layer for the finance stack. It accepts
Narwhals-compatible inputs such as pandas, Polars, numpy, and other supported
series-like objects, then returns ordinary matplotlib figures or Great Tables
objects that can be saved, embedded in notebooks, or composed into tearsheets.
The initial release focuses on a compact, useful surface:
Return/risk plots for cumulative returns, rolling volatility, rolling Sharpe, rolling beta/correlation, benchmark scatter, drawdowns, and period-return views.
Technical-indicator plots for price overlays, secondary-axis indicators, and indicator sub-panels.
Performance summary tables backed by
great-tables.Post-trade diagnostics for trading-cost breakdowns, MAE/MFE scatter, and execution-quality distributions.
Alpha-analysis plots for IC, quantile returns, turnover, and cumulative factor returns.
Install¶
pip install finance-plots
The gallery and documentation examples use the released data/calculation stack:
pip install "finance-plots[examples]"
Quick Start¶
Generate deterministic prices with finance-datagen, compute returns with
finance-calcs, and plot them with finance-plots.
from datetime import datetime, timezone
import polars as pl
from finance_datagen import generate_prices
import finance_calcs as fc
import finance_plots as fp
start_ms = int(datetime(2021, 1, 4, tzinfo=timezone.utc).timestamp() * 1000)
prices = generate_prices(symbol="ACME", seed=7, start_ms=start_ms)
returns = prices.with_columns(
fc.simple_returns(pl.col("price")).alias("ret"),
).select("ret").drop_nulls()["ret"]
fig = fp.plot_rolling_returns(returns)
Current Plot Catalog¶
Function |
Use it for |
|---|---|
|
Simple cumulative return path |
|
Cumulative return path with optional benchmark and out-of-sample shading |
|
Rolling annualized volatility |
|
Rolling annualized Sharpe ratio |
|
Rolling beta versus a benchmark |
|
Rolling correlation versus a benchmark |
|
Strategy returns against benchmark returns with a fitted beta line |
|
Filled underwater drawdown chart |
|
Year-by-month, year-by-quarter, or year-by-week return heatmap |
|
Compounded period returns as a bar chart |
|
Distribution of compounded period returns |
|
Compounded period returns through time |
|
Price line with moving averages and secondary-axis indicators |
|
Price chart with one or more aligned indicator sub-panels |
|
Trading cost attribution by component |
|
Maximum adverse versus favorable excursion by trade |
|
Implementation-shortfall distribution |
|
Information-coefficient time series with rolling mean |
|
Information-coefficient distribution |
|
Information-coefficient Q-Q plot |
|
Mean IC by sector/group |
|
Calendar heatmap of mean IC |
|
Rolling mean IC |
|
Mean return by signal quantile |
|
Top/bottom quantile turnover |
|
Compounded long-short factor return path |
Current Table Catalog¶
Function |
Use it for |
|---|---|
|
Dictionary of cumulative return, annualized return/volatility, Sharpe, Sortino, max drawdown, and Calmar |
|
Great Tables performance summary with optional benchmark column |
|
Great Tables period-return summary |
|
Great Tables largest-drawdown-period summary |
|
Great Tables trading-cost attribution summary |
|
Great Tables round-trip trade-quality summary |
|
Great Tables implementation-shortfall summary |
|
Great Tables information-coefficient summary |
|
Great Tables mean return by quantile |
|
Great Tables quantile-turnover summary |
|
Great Tables quantile counts and signal statistics |