Math Helpers¶
-
quant.common.math_helpers.
cal_mdd
(netvalue, compound=True)[源代码]¶ 计算最大回撤
Parameters: - netvalue: pd.Series
净值序列
- compound: bool, optional
是否为复利制,如果为真,回撤计算方法为 \(\frac{N_j}{N_i}-1\) (j > i); 如果为假,回撤计算方法为 \(N_j-N_i\) (j > i)
Returns: - 最大回撤值(正值)
Examples
In [1]: import pandas as pd In [2]: from quant.common.math_helpers import cal_mdd In [3]: series = pd.Series([1.0, 1.1, 1.11, 1.04, 1.02, 1.08]) In [4]: cal_mdd(series) Out[4]: 0.08108108108108114 In [5]: 1.02 / 1.11 - 1