Annualized Returns¶
-
perfana.core.returns.
annualized_returns
(r, freq=None, geometric=True)[source]¶ Calculates the annualized returns from the data
The formula for annualized geometric returns is formulated by raising the compound return to the number of periods in a year, and taking the root to the number of total observations:
\[\prod_i^N(1 + r_i)^{\frac{s}{N}} - 1\]where \(s\) is the number of observations in a year, and \(N\) is the total number of observations.
For simple returns (geometric=FALSE), the formula is:
\[\frac{s}{N} \sum^N_i r_i\]- Parameters
r (
Union
[DataFrame
,Iterable
[Union
[int
,float
]],ndarray
,Series
]) – Numeric returns series or data framefreq (
Optional
[str
]) – Frequency of the data. Use one of daily, weekly, monthly, quarterly, semi-annually, yearlygeometric – If True, calculates the geometric returns. Otherwise, calculates the arithmetic returns
- Returns
Annualized returns
- Return type
float or Series
Examples
>>> from perfana.datasets import load_etf >>> from perfana.core import annualized_returns # Get returns starting from the date where all etf has data >>> etf = load_etf().dropna().pa.to_returns().dropna() VBK 0.091609 BND 0.036224 VTI 0.081203 VWO 0.027670 dtype: float64 >>> annualized_returns(etf.VWO) 0.02767037698144148