Return charts

Interactive Plotly charts for return streams: quick column charts, equity curves, drawdowns, full performance reports, and calendar heatmaps. These code cells are executed live by Quarto every time the docs are built.

Sample data

We reuse qrt’s bundled sample datasets — AAPL as the “strategy” and SPY as the benchmark — loaded offline via q.data.datasets.load, no network dependency:

import pandas as pd

import qrt as q

aapl = q.data.datasets.load("aapl")
spy = q.data.datasets.load("spy")

returns = pd.concat(
    {
        "AAPL": aapl["close"].pct_change(),
        "SPY": spy["close"].pct_change(),
    },
    axis=1,
).dropna()
strategy = returns["AAPL"]
benchmark = returns["SPY"]

returns.tail()
AAPL SPY
datetime
2026-07-13 0.006311 -0.007656
2026-07-14 -0.007721 0.003551
2026-07-15 0.040145 0.003964
2026-07-16 0.017588 -0.005419
2026-07-17 0.001440 -0.009897

Quick column charts: q.plot.col

q.plot.col renders any Series/DataFrame column selection as an interactive line chart, with shell-style wildcard support (e.g. "*_ret") for selecting multiple columns at once:

fig = q.plot.col(returns, title="Daily returns", ylabel="Return")
fig.show()

Equity curve: q.plot.equity

Compounds a return stream into a growth-of-$1 curve:

fig = q.plot.equity(strategy, title="AAPL equity curve")
fig.show()

Drawdown: q.plot.drawdown

The underwater chart — cumulative drawdown from the running peak:

fig = q.plot.drawdown(strategy)
fig.show()

Full performance report: q.plot.plot

Combines the equity curve, drawdown, and headline stats (CAGR, Volatility, Sharpe, Max Drawdown) into one linked-axis figure. An optional benchmark overlays a second equity curve:

fig = q.plot.plot(strategy, benchmark=benchmark, title="AAPL vs. SPY")
fig.show()

Calendar returns: q.plot.monthly_heatmap

Year-by-month compounded returns as an interactive heatmap, pairing with q.stats.monthly_returns:

fig = q.plot.monthly_heatmap(strategy, title="AAPL monthly returns")
fig.show()
Back to top