diff --git a/yfinance_cache/yfc_financials_manager.py b/yfinance_cache/yfc_financials_manager.py index 06d9ccf..77d911b 100644 --- a/yfinance_cache/yfc_financials_manager.py +++ b/yfinance_cache/yfc_financials_manager.py @@ -416,15 +416,19 @@ def _get_interval_from_table(self, tbl): interval = None intervals = [(dates[i-1] - dates[i]).days for i in range(1,len(dates))] + intervals = np.array(intervals) sdm_thresold = 0.1 if len(intervals) == 1: interval = intervals[0] else: - avg = mean(intervals) - sdm = stdev(intervals) / avg + # First, discard impossibly small intervals: + f_too_small = intervals < 60 + if f_too_small.any(): + intervals = intervals[~f_too_small] + avg = np.mean(intervals) + sdm = np.std(intervals) / avg if sdm > sdm_thresold: # Discard large outliers - intervals = np.array(intervals) intervals = intervals[intervals