I am being rate limited in jupyter notebook for a single ticker when I haven't used yfinance in jupyter notebook in months #2503
Replies: 2 comments 2 replies
-
Resubmit with form |
Beta Was this translation helpful? Give feedback.
0 replies
-
give this a try: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am being rate limited when I havent used yfinance in ages in jupyter notebook with the following query:
import yfinance as yf
stock = yf.Ticker("CBA.AX")
info = stock.get_info() # Explicitly fetch info once
print(info.get("lastPrice"))
print(info.get("yearHigh"))
print(info.get("marketCap"))
Returns
YFRateLimitError Traceback (most recent call last)
Cell In[25], line 4
1 import yfinance as yf
3 stock = yf.Ticker("CBA.AX")
----> 4 info = stock.get_info() # Explicitly fetch info once
6 print(info.get("lastPrice"))
7 print(info.get("yearHigh"))
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/base.py:232, in TickerBase.get_info(self, proxy)
230 def get_info(self, proxy=None) -> dict:
231 self._quote.proxy = proxy or self.proxy
--> 232 data = self._quote.info
233 return data
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/scrapers/quote.py:508, in Quote.info(self)
505 @Property
506 def info(self) -> dict:
507 if self._info is None:
--> 508 self._fetch_info(self.proxy)
509 self._fetch_complementary(self.proxy)
511 return self._info
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/scrapers/quote.py:609, in Quote._fetch_info(self, proxy)
607 self._already_fetched = True
608 modules = ['financialData', 'quoteType', 'defaultKeyStatistics', 'assetProfile', 'summaryDetail']
--> 609 result = self._fetch(proxy, modules=modules)
610 result.update(self._fetch_additional_info(proxy))
611 if result is None:
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/scrapers/quote.py:587, in Quote._fetch(self, proxy, modules)
585 params_dict = {"modules": modules, "corsDomain": "finance.yahoo.com", "formatted": "false", "symbol": self._symbol}
586 try:
--> 587 result = self._data.get_raw_json(QUOTE_SUMMARY_URL + f"/{self._symbol}", user_agent_headers=self._data.user_agent_headers, params=params_dict, proxy=proxy)
588 except requests.exceptions.HTTPError as e:
589 utils.get_yf_logger().error(str(e))
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/data.py:428, in YfData.get_raw_json(self, url, user_agent_headers, params, proxy, timeout)
426 def get_raw_json(self, url, user_agent_headers=None, params=None, proxy=None, timeout=30):
427 utils.get_yf_logger().debug(f'get_raw_json(): {url}')
--> 428 response = self.get(url, user_agent_headers=user_agent_headers, params=params, proxy=proxy, timeout=timeout)
429 response.raise_for_status()
430 return response.json()
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/utils.py:104, in log_indent_decorator..wrapper(*args, **kwargs)
101 logger.debug(f'Entering {func.name}()')
103 with IndentationContext():
--> 104 result = func(*args, **kwargs)
106 logger.debug(f'Exiting {func.name}()')
107 return result
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/data.py:347, in YfData.get(self, url, user_agent_headers, params, proxy, timeout)
345 @utils.log_indent_decorator
346 def get(self, url, user_agent_headers=None, params=None, proxy=None, timeout=30):
--> 347 return self._make_request(url, request_method = self._session.get, user_agent_headers=user_agent_headers, params=params, proxy=proxy, timeout=timeout)
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/utils.py:104, in log_indent_decorator..wrapper(*args, **kwargs)
101 logger.debug(f'Entering {func.name}()')
103 with IndentationContext():
--> 104 result = func(*args, **kwargs)
106 logger.debug(f'Exiting {func.name}()')
107 return result
File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/yfinance/data.py:409, in YfData._make_request(self, url, request_method, user_agent_headers, body, params, proxy, timeout)
407 # Raise exception if rate limited
408 if response.status_code == 429:
--> 409 raise YFRateLimitError()
411 return response
YFRateLimitError: Too Many Requests. Rate limited. Try after a while.
Beta Was this translation helpful? Give feedback.
All reactions