summary¶
One-shot aggregate summaries built out of the other metric modules.
summary ¶
One-shot aggregate summaries built out of the other metric modules.
tearsheet_summary ¶
tearsheet_summary(
returns: Series,
prices: Series | None = None,
rf: float = DEFAULT_RISK_FREE_RATE,
periods_per_year: int = TRADING_DAYS_PER_YEAR,
) -> dict
Compute the key headline metrics in one call, each as a self-explaining MetricResult.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
returns
|
Series
|
Per-period returns. |
required |
prices
|
Series | None
|
Price series to use for price-based metrics (cagr,
max_drawdown). Defaults to a synthetic series reconstructed from
|
None
|
rf
|
float
|
Risk-free rate, as an annual rate. Defaults to DEFAULT_RISK_FREE_RATE. |
DEFAULT_RISK_FREE_RATE
|
periods_per_year
|
int
|
Number of periods in a year, used to annualize. |
TRADING_DAYS_PER_YEAR
|
Returns:
| Type | Description |
|---|---|
dict
|
A dict mapping metric name to its MetricResult. |
Source code in src/portpy/metrics/summary.py
compare_to_benchmark ¶
compare_to_benchmark(
returns: Series,
benchmark: Series,
rf: float = DEFAULT_RISK_FREE_RATE,
periods_per_year: int = TRADING_DAYS_PER_YEAR,
) -> pd.DataFrame
Side-by-side portfolio-vs-benchmark table: absolute metrics for both, plus relative metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
returns
|
Series
|
Per-period portfolio returns. |
required |
benchmark
|
Series
|
Per-period benchmark returns. |
required |
rf
|
float
|
Risk-free rate, as an annual rate. Defaults to DEFAULT_RISK_FREE_RATE. |
DEFAULT_RISK_FREE_RATE
|
periods_per_year
|
int
|
Number of periods in a year, used to annualize. |
TRADING_DAYS_PER_YEAR
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame indexed by metric name, with "portfolio", "benchmark", and |
DataFrame
|
"difference" columns. "benchmark" is NaN for metrics that are |
DataFrame
|
inherently relative (e.g. beta, alpha, information_ratio). |