I am running this code to get timeseries data for USDJPY:
from pandas_datareader import data
from pandas import Series, DataFrame
data.DataReader('JPY=X', 'yahoo', date(2020,6,15), date(2020,6,28))['Close']
This is producing the following:
Date
2020-06-14 107.310997
2020-06-15 107.463997
2020-06-16 107.410004
2020-06-17 106.893997
2020-06-18 107.005997
2020-06-21 106.831001
2020-06-22 106.903000
2020-06-23 106.431999
2020-06-24 107.043999
2020-06-25 107.154999
Name: Close, dtype: float64
These dates are wrong. 14 and 21 June 2020 were Sundays. The currency data is correct but the dates are all being shifted backwards by 1 day (i.e. 14 June 2020 should be 15 June 2020
I have the answer. Don't use DataReader for FX data. Use Alpha Vantage as follows:
import requests
Get = requests.get('https://www.alphavantage.co/query?function=FX_DAILY&from_symbol=usd&to_symbol=jpy&outputsize=full&apikey=XXXXXXXXXXXXXXX')
You will need to request an API key here.