views:

128

answers:

3

Hi,

I am writing a web app based on Django, and I hope to pick many of the good brains here on how I might be able to convert a price based on 1 static currency (say USD), to any other currencies?

Is there some feed or something I can parse to convert it on the fly?

Thanks.

A: 

Maybe reading an external source in the fly is detrimental to your application's latency, i.e. perceived user performance as you will depend on the source's availability and response time.

If real-time data is not required, you could have you own Model for exchange rate and update the data base table in the background every hour or day or so.

Ber
Yeah if it were me I'd set up a cron job to run on a regularity based on API allowances and the expected number of reads on that table.
ozan
+1  A: 

There are a two (probably abandoned) Django apps to handle currency issues:

Both of these projects include methods for doing currency conversions but will probably need some work before they are stable.

Then, you can update your table of exchange rates using a service like XE.com. If you're willing to pay for it you can update your rates every 60 seconds, but updating once a day is the cheapest.

As suggested by Ber and ozan, you can use cron or django-chronograph to schedule a script to run that does an HTTP GET to pull the data from XE, parses the data and then saves it into your models.

There are probably other services out there doing the same thing, so do some shopping before buying.

Van Gale
Just looked at xurrency.com linked by Dominic. That looks simple (although SOAP is a pain in Python). Their website doesn't mention how often the rates are updated though, which is weird.
Van Gale
+1  A: 

A little late to the party, but django-currencies isn't abandoned. Except from the auto-update the rates from a service it works swell. We already use it in a couple of our projects.

If somebody would like to help with adding syncing with a currency service let me know on the app's page and I'd be happy to work along.

panosl
That's good news and thanks for the update!
Van Gale