How can get ' USDJPY'(currency rates) with pandas and yahoo finance?

前端 未结 3 2050
别那么骄傲
别那么骄傲 2021-01-03 00:13

I am learning and using the pandas and python.

Today, I am trying to make a fx rate table, but I got a trouble with getting the pricess of \'USDJPY\'.

When I

相关标签:
3条回答
  • 2021-01-03 00:39

    Yahoo Finance doesn't provide historical data on exchange rates

    Yes it does but not on cross rates. All vs the USD List of Yahoo USD Exchange Rates

    a = web.DataReader("JPY=X", 'yahoo')
    
    0 讨论(0)
  • 2021-01-03 00:42

    Yahoo Finance doesn't provide historical data on exchange rates (i.e. there's no "Historical Prices" link in the top left of the page like there would be for stocks, indices, etc...)

    You can use FRED (Federal Reserve of St. Louis data) to get these exchange rates...

    import pandas.io.data as web
    
    jpy = web.DataReader('DEXJPUS', 'fred')
    

    UPDATE: hase moved the pandas-datareader

    from pandas_datareader import data
    jpy = data.DataReader('DEXJPUS', 'fred')
    

    or the more direct way...

    jpy = web.get_data_fred('DEXJPUS')
    

    A list of all of the exchange rate that FRED has daily data for can be found here: http://research.stlouisfed.org/fred2/categories/94

    0 讨论(0)
  • 2021-01-03 00:45

    Get the historical exchange rates from OANDA http://pandas-datareader.readthedocs.io/en/latest/remote_data.html

    In [1]: from pandas_datareader.oanda import get_oanda_currency_historical_rates
    In [2]: start, end = "2016-01-01", "2016-06-01"
    In [3]: quote_currency = "USD"
    In [4]: base_currency = ["EUR", "GBP", "JPY"]
    In [5]: df_rates = get_oanda_currency_historical_rates(
                start, end,
                quote_currency=quote_currency,
                base_currency=base_currency
            )
    In [6]: print(df_rates)
    

    Update: Oanda started charging for this lately https://www.oanda.com/fx-for-business/exchange-rates-api

    0 讨论(0)
提交回复
热议问题