diff --git a/pyfacts/utils.py b/pyfacts/utils.py index f212101..9cc4e2e 100644 --- a/pyfacts/utils.py +++ b/pyfacts/utils.py @@ -188,9 +188,15 @@ def _find_closest_date( """ if delta.days < 0 and date < min(data.data): - raise DateOutOfRangeError(date, "min") + if if_not_found == "nan": + return float("NaN"), float("NaN") + else: + raise DateOutOfRangeError(date, "min") if delta.days > 0 and date > max(data.data): - raise DateOutOfRangeError(date, "max") + if if_not_found == "nan": + return float("NaN"), float("NaN") + else: + raise DateOutOfRangeError(date, "max") row: tuple = data.get(date, None) if row is not None: