数据源:riquant下载到本地,data = herramiento.base_analysis()分析没有问题。
多时间周期分析出错。
intervals = ["5min","15min","30min","1h","2h","4h"]
herramiento.multi_time_frame_analysis(intervals=intervals)
2020-03-07 16:27:12.986966 第二步:随机性检验:纯随机性
2020-03-07 16:27:12.986966 白噪声检验结果:(array([nan]), array([nan]))
---------------------------------------------------------------------------
MissingDataError Traceback (most recent call last)
<ipython-input-5-7cd45c2bb58a> in <module>
1 # 多时间周期分析
2 intervals = ["5min","15min","30min","1h","2h","4h"]
----> 3 herramiento.multi_time_frame_analysis(intervals=intervals)
~\qvirs_tools\data_analysis.py in multi_time_frame_analysis(self, intervals, df)
257 data["volume"] = df["volume"].resample(interval, how="sum")
258
--> 259 result = self.base_analysis(data)
260 self.results[interval] = result
261
~\qvirs_tools\data_analysis.py in base_analysis(self, df)
128
129 random_test(close_price)
--> 130 stability_test(close_price)
131 autocorrelation_test(close_price)
132
~\qvirs_tools\data_analysis.py in stability_test(close_price)
304 def stability_test(close_price):
305 """"""
--> 306 statitstic = ADF(close_price)
307 t_s = statitstic[1]
308 t_c = statitstic[4]["10%"]
c:\vnstudio\lib\site-packages\statsmodels\tsa\stattools.py in adfuller(x, maxlag, regression, autolag, store, regresults)
266 if not regresults:
267 icbest, bestlag = _autolag(OLS, xdshort, fullRHS, startlag,
--> 268 maxlag, autolag)
269 else:
270 icbest, bestlag, alres = _autolag(OLS, xdshort, fullRHS, startlag,
c:\vnstudio\lib\site-packages\statsmodels\tsa\stattools.py in _autolag(mod, endog, exog, startlag, maxlag, method, modargs, fitargs, regresults)
93 method = method.lower()
94 for lag in range(startlag, startlag + maxlag + 1):
---> 95 mod_instance = mod(endog, exog[:, :lag], *modargs)
96 results[lag] = mod_instance.fit()
97
c:\vnstudio\lib\site-packages\statsmodels\regression\linear_model.py in __init__(self, endog, exog, missing, hasconst, **kwargs)
857 **kwargs):
858 super(OLS, self).__init__(endog, exog, missing=missing,
--> 859 hasconst=hasconst, **kwargs)
860 if "weights" in self._init_keys:
861 self._init_keys.remove("weights")
c:\vnstudio\lib\site-packages\statsmodels\regression\linear_model.py in __init__(self, endog, exog, weights, missing, hasconst, **kwargs)
700 weights = weights.squeeze()
701 super(WLS, self).__init__(endog, exog, missing=missing,
--> 702 weights=weights, hasconst=hasconst, **kwargs)
703 nobs = self.exog.shape[0]
704 weights = self.weights
c:\vnstudio\lib\site-packages\statsmodels\regression\linear_model.py in __init__(self, endog, exog, **kwargs)
188 """
189 def __init__(self, endog, exog, **kwargs):
--> 190 super(RegressionModel, self).__init__(endog, exog, **kwargs)
191 self._data_attr.extend(['pinv_wexog', 'wendog', 'wexog', 'weights'])
192
c:\vnstudio\lib\site-packages\statsmodels\base\model.py in __init__(self, endog, exog, **kwargs)
234
235 def __init__(self, endog, exog=None, **kwargs):
--> 236 super(LikelihoodModel, self).__init__(endog, exog, **kwargs)
237 self.initialize()
238
c:\vnstudio\lib\site-packages\statsmodels\base\model.py in __init__(self, endog, exog, **kwargs)
75 hasconst = kwargs.pop('hasconst', None)
76 self.data = self._handle_data(endog, exog, missing, hasconst,
---> 77 **kwargs)
78 self.k_constant = self.data.k_constant
79 self.exog = self.data.exog
c:\vnstudio\lib\site-packages\statsmodels\base\model.py in _handle_data(self, endog, exog, missing, hasconst, **kwargs)
98
99 def _handle_data(self, endog, exog, missing, hasconst, **kwargs):
--> 100 data = handle_data(endog, exog, missing, hasconst, **kwargs)
101 # kwargs arrays could have changed, easier to just attach here
102 for key in kwargs:
c:\vnstudio\lib\site-packages\statsmodels\base\data.py in handle_data(endog, exog, missing, hasconst, **kwargs)
670 klass = handle_data_class_factory(endog, exog)
671 return klass(endog, exog=exog, missing=missing, hasconst=hasconst,
--> 672 **kwargs)
c:\vnstudio\lib\site-packages\statsmodels\base\data.py in __init__(self, endog, exog, missing, hasconst, **kwargs)
85 self.const_idx = None
86 self.k_constant = 0
---> 87 self._handle_constant(hasconst)
88 self._check_integrity()
89 self._cache = {}
c:\vnstudio\lib\site-packages\statsmodels\base\data.py in _handle_constant(self, hasconst)
131 exog_max = np.max(self.exog, axis=0)
132 if not np.isfinite(exog_max).all():
--> 133 raise MissingDataError('exog contains inf or nans')
134 exog_min = np.min(self.exog, axis=0)
135 const_idx = np.where(exog_max == exog_min)[0].squeeze()
MissingDataError: exog contains inf or nans
源码都看了,是数据本身的问题?