pyform.returns.compound.
compound
Factory for producing compound functions.
method –
method of compounding in the generated function
’geometric’: geometric compounding (1+r1) * (1+r2) - 1
(1+r1) * (1+r2) - 1
’arithmetic’: arithmetic compounding r1 + r2
r1 + r2
’continuous’: continous compounding exp(r1+r2) - 1
exp(r1+r2) - 1
ValueError – when method is not supported.
compound it according to the method specified.
Callable
compound_arithmetic
Performs arithmatic compounding.
e.g. if there are 3 returns r1, r2, r3, calculate r1 + r2 + r3
returns – pandas series of returns, in decimals. i.e. 3% should be expressed as 0.03, not 3.
total compounded return
float
compound_continuous
Performs continuous compounding.
e.g. if there are 3 returns r1, r2, r3, calculate exp(r1 + r2 + r3) - 1
compound_geometric
Performs geometric compounding.
e.g. if there are 3 returns r1, r2, r3, calculate (1+r1) * (1+r2) * (1+r3) - 1
cumseries
’geometric’: geometric compounding
’arithmetic’: arithmetic compounding
’continuous’: continous compounding
compound it to create a cumulative index sereis according to the method specified.
cumseries_arithmetic
Performs arithmatic compounding to create cumulative index series.
e.g. if there are 3 returns r1, r2, r3, calculate
r1 r1 + r2 r1 + r2 + r3
pandas series of cumulative index, in decimals.
returns
cumseries_continuous
Performs continuous compounding to create cumulative index series.
exp(r1) - 1 exp(r1 + r2) - 1 exp(r1 + r2 + r3) - 1
cumseries_geometric
Performs geometric compounding to create cumulative index series.
(1+r1) - 1, (1+r1) * (1+r2) - 1, (1+r1) * (1+r2) * (1+r3) - 1
ret_to_period
Converts return series to a different (and lower) frequency.
df – a time indexed pandas dataframe
freq – frequency to convert the return series to. Available options can be found here.
compounding method when converting to lower frequency.
return series in desired frequency
pd.DataFrame
pyform.returns.metrics.
calc_ann_ret
Computes annualized return of a time indexed pandas series
series – a time indexed pandas DataFrame or Series of returns
method – {‘geometric’, ‘arithmetic’, ‘continuous’}. method used to compound returns
years – Useful when you want to specify how many years are actually in the data.
annualized volatility
calc_ann_vol
Computes annualized volatility of a time indexed pandas series
method – {‘sample’, ‘population’}. method used to compute volatility (standard deviation).
samples_per_year – Useful when you want to specify how many samples are there per year so annualization can be done properly. If None, this will be computed by using the series supplied. Defaults to None.