mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-01 12:20:21 +08:00
TEST: Don't mask unexpected exceptions from TALIB.
We know when we expect the error to be raised.
This commit is contained in:
@@ -72,17 +72,17 @@ class BollingerBandsTestCase(WithTechnicalFactor, ZiplineTestCase):
|
||||
middle_cols = []
|
||||
upper_cols = []
|
||||
for n in range(self.nassets):
|
||||
try:
|
||||
close_col = closes[:, n]
|
||||
if np.isnan(close_col).all():
|
||||
# ta-lib doesn't deal well with all nans.
|
||||
upper, middle, lower = [np.full(self.ndays, np.nan)] * 3
|
||||
else:
|
||||
upper, middle, lower = talib.BBANDS(
|
||||
closes[:, n],
|
||||
window_length,
|
||||
k,
|
||||
k,
|
||||
)
|
||||
except Exception:
|
||||
# If the input array is all nan then talib raises an instance
|
||||
# of Exception.
|
||||
upper, middle, lower = [np.full(self.ndays, np.nan)] * 3
|
||||
|
||||
upper_cols.append(upper)
|
||||
middle_cols.append(middle)
|
||||
|
||||
Reference in New Issue
Block a user