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-17 0.001440 -0.009897
2026-07-20 -0.021424 -0.001614
2026-07-21 0.003521 0.008341
2026-07-22 -0.005645 -0.001163
2026-07-23 -0.012980 -0.012349

Quick line charts: q.plot.line

q.plot.line 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.line(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.performance

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.performance(returns=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(returns=strategy, title="AAPL monthly returns")
fig.show()
Back to top