Skip to content

Commit 76c8ee0

Browse files
committed
fix: work around yfinance get_history_metadata() bug
get_history_metadata() triggers a second intraday request (5d/1h) that fails for some tickers (e.g., ROG.SW). Read currency directly from internal metadata already populated by history(). See ranaroussi/yfinance#2745
1 parent 42b6ffd commit 76c8ee0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎tessa/price/yahoo.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ def get_price_history(
3434
df.index.name = "date"
3535
df.rename(columns={"Close": "close"}, inplace=True)
3636

37-
return PriceHistory(df, ticker.get_history_metadata()["currency"])
37+
# Get currency from metadata already populated by history() above.
38+
# Don't use get_history_metadata() — it triggers a second intraday request
39+
# that fails for some tickers. See https://github.com/ranaroussi/yfinance/issues/2745
40+
# TODO Revert to get_history_metadata() once the issue is fixed in yfinance.
41+
currency = ticker._price_history._history_metadata["currency"]
42+
return PriceHistory(df, currency)

0 commit comments

Comments
 (0)