quantlab.factor.kunquant_ts.CMRA#
- class quantlab.factor.kunquant_ts.CMRA(v, months=12, month_length=21)[source]#
Bases:
CompositiveOpUSE4’s cumulative range of monthly returns, from a series of daily log returns.
With
Z(T)the sum ofvover the lastT * month_lengthbars,T = 1 .. months:CMRA = log(1 + max_T Z(T)) - log(1 + min_T Z(T))
as in USE4’s Residual Volatility (
vis the daily log excess returnlog(1 + r) - log(1 + r_f), 12 months of 21 days). A missing value adds nothing to a sum. NaN for the firstmonths * month_length - 1bars, and wheremin_T Z(T) <= -1, whose log is undefined. KunQuant’sLogis accurate to about 4e-10 absolute in double, so is the result.- Parameters:
- vOpBase
Daily log (excess) returns.
- monthsint, default 12
Number of trailing months.
- month_lengthint, default 21
Bars in one month.
- Raises:
- ValueError
If
monthsormonth_lengthis below 1.
Examples
>>> log_excess = Log(1.0 + Input("ret")) - Log(1.0 + Input("rf")) >>> Output(CMRA(log_excess, 12, 21), "cmra")