1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-12 15:26:54 +08:00

Fix ops bug & add raise comments of Skew Kurt

This commit is contained in:
bxdd
2020-11-24 12:29:45 +00:00
committed by you-n-g
parent 7152f8321b
commit 67e7fdf80b

View File

@@ -16,9 +16,8 @@ try:
from ._libs.rolling import rolling_slope, rolling_rsquare, rolling_resi from ._libs.rolling import rolling_slope, rolling_rsquare, rolling_resi
from ._libs.expanding import expanding_slope, expanding_rsquare, expanding_resi from ._libs.expanding import expanding_slope, expanding_rsquare, expanding_resi
except ImportError as err: except ImportError as err:
print(err) print("Do not import qlib package in the repository directory!")
print("Do not import qlib package in the repository directory") raise
sys.exit(-1)
__all__ = ( __all__ = (
"Ref", "Ref",
@@ -854,6 +853,8 @@ class Skew(Rolling):
""" """
def __init__(self, feature, N): def __init__(self, feature, N):
if N != 0 and N < 3:
raise ValueError("The rolling window size of Skewness operation should >= 3")
super(Skew, self).__init__(feature, N, "skew") super(Skew, self).__init__(feature, N, "skew")
@@ -874,6 +875,8 @@ class Kurt(Rolling):
""" """
def __init__(self, feature, N): def __init__(self, feature, N):
if N != 0 and N < 4:
raise ValueError("The rolling window size of Kurtosis operation should >= 5")
super(Kurt, self).__init__(feature, N, "kurt") super(Kurt, self).__init__(feature, N, "kurt")
@@ -1257,7 +1260,7 @@ class WMA(Rolling):
def weighted_mean(x): def weighted_mean(x):
w = np.arange(len(x)) w = np.arange(len(x))
w /= w.sum() w = w / w.sum()
return np.nanmean(w * x) return np.nanmean(w * x)
if self.N == 0: if self.N == 0: