Programmatically access Currency Exchange Rates from Yahoo Finance by Date
Asked Answered
E

4

14

I found the answer to this question VERY useful, but I would like to also get exchange rates for dates in the past, not just today's exchange rates. I'm writing an iPhone app that uses the exchange rate to calculate money made from sales in different countries.

Here's the example from the answer mentioned above to get today's echange rate for GBP to EUR: http://download.finance.yahoo.com/d/quotes.csv?s=GBPEUR=X&f=sl1d1t1ba&e=.csv

Does anyone know how to do this for any other dates? THANK YOU!

Ecumenicalism answered 24/8, 2012 at 18:24 Comment(0)
D
14

To retrieve historical data of currency exchange rates, you can't use Yahoo Finance. Their API only offers historical data of stocks. For example for APPLE between April the 1st 2003 and July, 30:

http://ichart.finance.yahoo.com/table.csv?s=AAPL&a=3&b=1&c=2003&d=6&e=30&f=2003&g=d&ignore=.csv

So, in your case you need to dig somewhere else. The only other main API available is OpenExchangeRate: http://openexchangerates.org/documentation#historical-data

Notice:

Important: From end August 2012, you will need an App ID to query the Open Exchange Rates API - it's free for personal use, and cheap for apps and commercial uses.

Other option:

You could use this: Free Forex Historical Data and then use Yahoo Finance (Currency Rates) each day (at your convenience) to construct an up-to-date table with all your currencies rates needed.

EDIT

The FED offers you historical data of many currencies rates. See Data Download Program to retrieve (csv, xls, xml) historical data. You can adapt it to your needs.

Disinherit answered 24/8, 2012 at 19:55 Comment(1)
That FED Data is the ticket. Thank you very much.Ecumenicalism
B
2

Actually, there is a way to get exchange rates historical data for free from Yahoo Finance.

Sample YQL console results(e.g USD/EUR exchange rate for 2015-09-03) by URL: https://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=select+*+from+yahoo.finance.historicaldata+where+symbol+%3D+%22EUR%3DX%22+and+startDate+%3D+%222015-09-03%22+and+endDate+%3D+%222015-09-03%22

Corresponding direct link https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22UAH%3DX%22%20and%20startDate%20%3D%20%222015-09-03%22%20and%20endDate%20%3D%20%222015-09-03%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=

or via YQL query like

select * from yahoo.finance.historicaldata where symbol = "EUR=X" and startDate = "2015-09-03" and endDate = "2015-09-03"
Bellyache answered 6/9, 2015 at 23:2 Comment(0)
S
1

You CAN use ichart.finance for currency as well. Use it just as Romain suggested for stocks. For US Dollar to South Korean Won, for example, use the symbol "KRW=X" in your query, i.e., instead of s=AAPL, use s=KRW=X.

Seagoing answered 17/1, 2013 at 6:4 Comment(0)
D
1

If you would like to use JSON API, then I would suggest using this Forex Exchange API, which is using Yahoo Finance rate.

I have implemented this for few of my customers, so far no issues have been reported from this currency exchange API though it's free currency exchange API.

Drape answered 23/6, 2014 at 9:29 Comment(1)
I don't believe Forex X-rate would be hosted on herokuapp.comMinda

© 2022 - 2024 — McMap. All rights reserved.