Relative Returns¶
-
perfana.core.returns.
relative_returns
(ra, rb, prefixes=('PRT', 'BMK'))[source]¶ Calculates the ratio of the cumulative performance for two assets through time
- Parameters
ra (
Union
[DataFrame
,Iterable
[Union
[int
,float
]],ndarray
,Series
]) – The assets returns vector or matrixrb (
Union
[DataFrame
,Iterable
[Union
[int
,float
]],ndarray
,Series
]) – The benchmark returnsprefixes – Prefix to apply to overlapping column names in the left and right side, respectively. This is also applied when the column name is an integer (i.e. 0 -> PRT_0). It is the default name of the Series data if there are no name to the Series
- Returns
Returns a DataFrame of the cumulative returns ratio between 2 asset classes. Returns a Series if there is only 2 compared classes.
- Return type
TimeSeriesData
Examples
>>> from perfana.datasets import load_etf >>> from perfana.core import relative_returns # Get returns starting from the date where all etf has data >>> etf = load_etf().dropna().pa.to_returns().dropna() >>> relative_returns(etf.tail(), etf.VBK.tail()) VBK/VBK BND/VBK VTI/VBK VWO/VBK Date 2019-02-25 1.0 0.996027 0.997856 1.009737 2019-02-26 1.0 1.004013 1.002591 1.013318 2019-02-27 1.0 0.997005 0.997934 1.000389 2019-02-28 1.0 1.001492 1.001461 0.998348 2019-03-01 1.0 0.987385 0.997042 0.988521