Hello,
I need help on how to download forex data for all currency pairs using python programming?
Hi,
You can refer to the below code to get the forex data for a currency pair using Yahoo Finance.
import yfinance as yf
import pandas as pd
# Set the ticker as 'EURUSD=X'
forex_data = yf.download('EURUSD=X', start='2023-01-02')
# Set the index to a datetime object
forex_data.index = pd.to_datetime(forex_data.index)
# Display the last five rows
forex_data.tail()
You can change the currency pair in the code as per the requirement. Also, you can check out the Getting Market Data course to know more about fetching market data.
Hope this helps!
Thanks,
Akshay
Thanks a lot Akshay Choudhary. This is very helpful ???