Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions qlib/data/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
from ._libs.rolling import rolling_slope, rolling_rsquare, rolling_resi
from ._libs.expanding import expanding_slope, expanding_rsquare, expanding_resi
except ImportError as err:
print(err)
print("Do not import qlib package in the repository directory")
sys.exit(-1)
print("Do not import qlib package in the repository directory!")
raise

__all__ = (
"Ref",
Expand Down Expand Up @@ -854,6 +853,8 @@ class Skew(Rolling):
"""

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")


Expand All @@ -874,6 +875,8 @@ class Kurt(Rolling):
"""

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")


Expand Down Expand Up @@ -1257,7 +1260,7 @@ def _load_internal(self, instrument, start_index, end_index, freq):

def weighted_mean(x):
w = np.arange(len(x))
w /= w.sum()
w = w / w.sum()
return np.nanmean(w * x)

if self.N == 0:
Expand Down