yahoo: More graceful handling of responses with meta but no timestamps.

This commit is contained in:
Chris Berkhout 2024-09-15 12:59:39 +02:00
parent ee8ca0573d
commit 77b2776e55

View file

@ -146,11 +146,10 @@ class Yahoo(BaseSource):
raise exceptions.InvalidPair(
series.base, series.quote, self, "Symbol not found."
)
if code == 400 and "Data doesn't exist" in text:
elif code == 400 and "Data doesn't exist" in text:
raise exceptions.BadResponse(
"No data for the given interval. Try requesting a larger interval."
)
elif code == 404 and "Timestamp data missing" in text:
raise exceptions.BadResponse(
"Data missing. The given interval may be for a gap in the data "
@ -169,4 +168,10 @@ class Yahoo(BaseSource):
"The data couldn't be parsed. "
) from e
if "timestamp" not in data["chart"]["result"][0]:
raise exceptions.BadResponse(
"No data for the given interval. "
"There may be a problem with the symbol or the interval."
)
return data