Headline return-stream metrics and benchmark-relative statistics. 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:
q.stats.performance returns a pandas Series of Total Return, CAGR, Volatility, Sharpe, Sortino, Calmar, Max Drawdown, Win Rate, and Periods. The annualization frequency is inferred from the index (252 for this daily series) unless periods_per_year is given explicitly. Win Rate excludes exact-zero-return periods from both the numerator and denominator:
q.stats.performance(strategy)
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
CAGR, Sharpe, Sortino, and Calmar all accept an optional annualized risk-free rate rf (deannualized internally and subtracted from returns before the ratio is computed). This lowers the ratios versus the rf=0.0 default above:
q.stats.beta measures sensitivity to the benchmark; q.stats.alpha is the annualized Jensen alpha unexplained by that beta exposure. q.stats.benchmark_stats combines both with active return, correlation, tracking error, and information ratio:
Strategy Total Return 397.388914
Benchmark Total Return 7.156124
Active Return 47.845375
Beta 1.129829
Alpha 0.191889
Correlation 0.569082
Tracking Error 0.316003
Information Ratio 0.647454
Periods 6673.000000
Name: AAPL vs SPY, dtype: float64