My first stop was at Luma (www.luma.co.nz), at an article titled "Making Currency Conversion Easier for the Web" - (http://www.luma.co.nz/featured/making-currency-conversion-easier-for-the-web/). The article suggests that there are three methods to add a currency converter to your site:
1. Using Webservices.
2. Using an iframe to display a conversion tool provided by another site. The site suggested Google Finance (http://www.google.com/finance/converter?a=100&from=EGP&to=USD) as a candidate for this method. Google Finance provides a clean interface however, if you want to apply the currency changes to all prices on your site instead of just showing a conversion calculator then this is not the answer here.
3. Pull the exchange rates from an external source.
Luma provides a tool for obtaining a copy of the free exchange rate XML feed from the European Central Bank (http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html) and generates either Java script or Ruby for doing conversions.
The idea there is to create a task that runs periodically on your server to refresh your copy of the data.
Although Luma's idea is good and is backed up with a good effort to create these tools, My reluctance to use this idea is due to the fact that it is written in Ruby - which I am no expert of - and so I will be relying on a piece of code that I will have trouble changing.
My other concern here is that we are now relying on an administrative task for executing our data update. I prefer to keep all my business logic inside my code, agree with me or not, I think of the update interval as part of the business logic. So on I go.
My next stop was at thomasknierim.com. They provide source code for a Currency Converter that also uses the XML feed from the European Central Bank to do currency conversions in Java.
The source code is provided and it uses a similar concept as Luma's, it caches the data and provides an update policy and mechanism for managing the data integrity and interface methods for conversion. Brilliant.
Another mechanism to do this without keeping cache would be to use Yahoo Finance. Yahoo Finance provides a way for obtaining conversion data using a URL that provides CSV (Comma Seperated Value).
The CSV is small, easy to parse and is timestamped.
For some reason I am still to figure out, the rates obtained from Yahoo Finance is different data I found on other sites like Oanda (http://www.oanda.com/). Oanda offers a service for publishers, it provides them with an XML or a CSV that is regularly updated. This service costs 200$ per month.
No comments:
Post a Comment