'How do you get USD JPY currency Data using yfinance API

Hi I am trying to get forex data from yahoo finance but keep getting errors so far what i did is:

USD_JPY = yf.Ticker("USDJPY=X")
hist = USD_JPY(period="max")

GET THE FOLLOWING MODULE UNCALLABLE.



Solution 1:[1]

You are missing the .history() when accessing your Ticker object.

import yfinance as yf

USD_JPY = yf.Ticker("USDJPY=X")
df_usd_jpy = USD_JPY.history(periods="max")
df_usd_jpy.head()

Output:

Open    High    Low Close   Volume  Dividends   Stock Splits
Date                            
2022-02-25  115.546997  115.630997  115.152000  115.570999  0   0   0
2022-02-28  115.587997  115.647003  115.093002  115.584999  0   0   0
2022-03-01  115.082001  115.264999  114.719002  115.078003  0   0   0
2022-03-02  114.815002  115.680000  114.794998  114.833000  0   0   0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KarelZe