quantlab.factor.kunquant_ts.CMRA#

class quantlab.factor.kunquant_ts.CMRA(v, months=12, month_length=21)[source]#

Bases: CompositiveOp

USE4’s cumulative range of monthly returns, from a series of daily log returns.

With Z(T) the sum of v over the last T * month_length bars, T = 1 .. months:

CMRA = log(1 + max_T Z(T)) - log(1 + min_T Z(T))

as in USE4’s Residual Volatility (v is the daily log excess return log(1 + r) - log(1 + r_f), 12 months of 21 days). A missing value adds nothing to a sum. NaN for the first months * month_length - 1 bars, and where min_T Z(T) <= -1, whose log is undefined. KunQuant’s Log is 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 months or month_length is below 1.

Examples

>>> log_excess = Log(1.0 + Input("ret")) - Log(1.0 + Input("rf"))
>>> Output(CMRA(log_excess, 12, 21), "cmra")
decompose(options)[source]#

Expand into one window sum per month, a running max and min, and two logs.