Showing posts with label History. Show all posts
Showing posts with label History. Show all posts

Tuesday, January 14, 2014

How to get today's exchange rate and historical data.

To get today's exchange rate we need to go to yahoo console. Query "yahoo.finance.xchange" object with pairs of currencies we want. Link with query to get today's exchange rate between pairs EUR-USD and GBP-USD from Yahoo:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22EURUSD%22%2C%22GBPUSD%22)&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

URL is easy to parse and to create. It will return JSON with needed rates.

But getting historical data is a little bit harder. Yahoo do not give us historical data of currency. But on Yahoo website exists page Currency Converter, that have exchange rate for any currency for any date. In the end of page there is note that data is taken from another sources: Commodity Systems and Thomson Financial Network. Analyzing network data that is sent to server we found URL:

http://finance.yahoo.com/connection/currency-converter-cache?date=20140102

This link returns us JSON object of exchange rate all currencies to USD. You can change parameter 'date' in URL and get rate for specific date.

Enjoy.