q.stats.returns(...) binds a return stream (and optional benchmark) once and exposes the same stats as methods. These code cells are executed live by Quarto every time the docs are built.
Real return streams
We use qrt’s bundled sample datasets — AAPL as the “strategy” and SPY as the benchmark — loaded offline via q.data.datasets.load, no network dependency:
For notebook exploration, q.stats.returns() binds a return stream (and optional benchmark) once and exposes the same stats as methods, plus .plot(kind=...) which delegates to q.plot. Each call creates a fresh, independent object — there is no hidden global state to reason about:
Total Return 397.388914
CAGR 0.253714
Volatility 0.383092
Sharpe 0.789598
Sortino 1.128677
Calmar 0.310158
Max Drawdown -0.818014
Win Rate 0.525824
Periods 6673.000000
Name: AAPL, dtype: float64
kind accepts "performance"/"tearsheet" (equity + drawdown report), "equity", "drawdown", or "monthly_heatmap". The bound benchmark is passed through automatically for the report variants: