Skip to content

Commit

Permalink
Fix cach: API deleted key
Browse files Browse the repository at this point in the history
  • Loading branch information
R5dan committed Dec 16, 2024
1 parent fd309bd commit 2d1ed95
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions yfinance/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ def __init__(self, region:'str', session=None, proxy=None, timeout=30, raise_err
self._data = YfData(session=self.session)
self._logger = utils.get_yf_logger()
self.next_req = 0

self._raw_data = {}

self._close = None
self._open = None
self._time = None
self._tz = None
self._is_open = None

self._parse_data(True)

Expand All @@ -42,8 +50,7 @@ def _fetch_data(self):
try:
data = data.json()
self._raw_data = data["finance"]["marketTimes"][0]["marketTime"][0]
type_change = self._raw_data["duration"][0]
self.next_req = time.time() + int(type_change["hrs"])*3600 + int(type_change["mins"])*60
self.next_req = dt.fromisoformat(self._raw_data["close"] if self._raw_data["status"] == "open" else self._raw_data["open"]).timestamp()
except _json.JSONDecodeError:
self._logger.error(f"{self.region}: Failed to retrieve market statusand recieved faulty data.")
self._raw_data = {}
Expand Down

0 comments on commit 2d1ed95

Please sign in to comment.