Closed jq419 closed 1 year ago
Hello @jq419,
Please fill out the following:
Which version are you running? The lastest version is on Github. Pip is for major releases.
import pandas_ta as ta
print(ta.version)
Do you have TA Lib also installed in your environment?
$ pip list
Have you tried the development version? Did it resolve the issue?
$ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development
Describe the bug A clear and concise description of what the bug is.
To Reproduce Provide sample code.
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Kind Regards, KJ
For ta version - 0.3.14b0
No I don't have TA Lib installed cause I am using MacBook M1. I have tried before but it give me error about CPU type.
I haven't tried the development version.
When I execute the following code, it give me error.
df = pd.DataFrame()
df_gbp = df.ta.ticker("GBPUSD=X")
df_gbp = df_gbp.drop(['Dividends', 'Stock Splits'], axis=1)
df_gbp.ta.strategy("Momentum")
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
Cell In[2], line 2
1 df = pd.DataFrame()
----> 2 df_gbp = df.ta.ticker("GBPUSD=X")
3 df_gbp = df_gbp.drop(['Dividends', 'Stock Splits'], axis=1)
4 df_gbp.ta.strategy("Momentum")
File ~/miniforge3/envs/tensorflow-gpu/lib/python3.9/site-packages/pandas_ta/core.py:851, in AnalysisIndicators.ticker(self, ticker, **kwargs)
849 ds = ds.lower() is not None and isinstance(ds, str)
850 # df = av(ticker, **kwargs) if ds and ds == "av" else yf(ticker, **kwargs)
--> 851 df = yf(ticker, **kwargs)
853 if df is None: return
854 elif df.empty:
File ~/miniforge3/envs/tensorflow-gpu/lib/python3.9/site-packages/pandas_ta/utils/data/yahoofinance.py:103, in yf(ticker, **kwargs)
100 df.name = ticker
102 try:
--> 103 ticker_info = yfd.info
104 except KeyError as ke:
105 print(f"[X] Ticker '{ticker}' not found.")
File ~/miniforge3/envs/tensorflow-gpu/lib/python3.9/site-packages/yfinance/ticker.py:138, in Ticker.info(self)
136 @property
137 def info(self) -> dict:
--> 138 return self.get_info()
File ~/miniforge3/envs/tensorflow-gpu/lib/python3.9/site-packages/yfinance/base.py:1475, in TickerBase.get_info(self, proxy)
1473 def get_info(self, proxy=None) -> dict:
1474 self._quote.proxy = proxy
-> 1475 data = self._quote.info
1476 return data
File ~/miniforge3/envs/tensorflow-gpu/lib/python3.9/site-packages/yfinance/scrapers/quote.py:98, in Quote.info(self)
94 @property
95 def info(self) -> dict:
96 if self._info is None:
97 # self._scrape(self.proxy) # decrypt broken
---> 98 self._fetch(self.proxy)
100 self._fetch_complementary(self.proxy)
102 return self._info
File ~/miniforge3/envs/tensorflow-gpu/lib/python3.9/site-packages/yfinance/scrapers/quote.py:248, in Quote._fetch(self, proxy)
245 return
246 self._already_fetched = True
--> 248 result = self._data.get_raw_json(
249 _BASIC_URL_, params={"formatted": "true", "lang": "en-US", "symbols": self._data.ticker}, proxy=proxy
250 )
251 query1_info = next(
252 (info for info in result.get("quoteResponse", {}).get("result", []) if info["symbol"] == self._data.ticker),
253 None,
254 )
255 for k, v in query1_info.items():
File ~/miniforge3/envs/tensorflow-gpu/lib/python3.9/site-packages/yfinance/data.py:209, in TickerData.get_raw_json(self, url, user_agent_headers, params, proxy, timeout)
207 def get_raw_json(self, url, user_agent_headers=None, params=None, proxy=None, timeout=30):
208 response = self.get(url, user_agent_headers=user_agent_headers, params=params, proxy=proxy, timeout=timeout)
--> 209 response.raise_for_status()
210 return response.json()
File ~/miniforge3/envs/tensorflow-gpu/lib/python3.9/site-packages/requests/models.py:1021, in Response.raise_for_status(self)
1016 http_error_msg = (
1017 f"{self.status_code} Server Error: {reason} for url: {self.url}"
1018 )
1020 if http_error_msg:
-> 1021 raise HTTPError(http_error_msg, response=self)
HTTPError: 401 Client Error: Unauthorized for url: https://query1.finance.yahoo.com/v7/finance/quote?formatted=true&lang=en-US&symbols=GBPUSD%3DX
@jq419,
Thanks for giving me more information. As a side note, I am also using an M1 Macbook and was able to get TA Lib installed; though I admit it is a bit tricky to install.
Note: Pandas TA only provides a simple wrapper around yfinance
. Since I am not the maintainer of the yfinance
package, I recommend making an Issue on their repo for additional help. Perhaps there is some networking issue on your end preventing the HTTP call? 🤷🏼♂️
Lastly, I had no problem calling ticker "GBPUSD=X" with Pandas TA v0.3.14b as shown below.
Hope this helps! 🍀 KJ
Seem Yahoo has blocked it. Would be great if this can be resolved cause it's the easiest way to get historical data.
401 Client Error: Unauthorized for url: https://query1.finance.yahoo.com/v7/finance/quote?formatted=true&lang=en-US&symbols=