Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Centralized database for up-to-date currency rates? 1

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
0
0
FR
Hello,

I have a shopping cart I had built on my own and I'd like to know if there is any way I could implement a system that would switch the whole website from one currency to another.

The whole thing is programmed in PHP and I would need to connect to some centralized database containing up-to-date rates.

I don't know were to start because I know nothing about currency conversion.

One thing for sure : I want to avoid systems where users have to do the conversions by themselves for each price.

In case I have no choice but to create my own database, how often are the rates supposed to change?

Thanks for helping! ;)

 
Like CoreyBryant has said, currency rates change minute-by-minute. But you can generally get by with the noon buying rates for any 24-hour period.

There are a number of websites that provide the information online:
The Bank of Canada
The U.S. Federal Reserve

I don't know where you are located, but your home nation's banking system probably provides this data. Just keep in mind that this data is for wholesale exchanges of data -- the rate for smaller exchanges may not be as favorable.

If your site accepts credit cards, you might look to see whether you credit-card clearinghouse can provide that data, too.

You could then have a scheduled script daily fetch the data and populate your exchange rates database.




Want the best answers? Ask the best questions!

TANSTAAFL!!
 

Hello CoreyBryant and sleipnir214.

Well, it would be a good option to use the so-called "noon buying rates" so that I could access the data once a day. But where/how to do that!?

Usually, online information are HTML formated tables without particular database connectivity. Well, I've failed to find one if it ever existed. One solution would be to open a remote HTML file with PHP and to parse it in order to populate the data automatically, but relying on an external source like that is a very bad idea in my opinion. Changes are likely to happen.

Also, using a credit card system wouldn't help since I want to have the currency changed in the whole site.

Still at point 0 ;)

Thanks again for your input.
 
I only provided a couple of quick examples. But the link to the Bank of Canada has on that human-readable page a link to the exchange rate data in CSV format.

A Google query of '"exchange rates" CSV' provided a number of sites around the world that provide noon-trading numbers for exchange rates, including sites run by the U.S. Federal Reserve Bank and the European Central Bank. The data is also readily available in XML.

Whether CSV or XML, a PHP script can fetch the page, parse the data, and update the exchange-rate table in your database. The rest of your application can then use the data in your exchange-rates table for the rest of the 24 hours until the new rates are posted.

The method of automatically daily running the exchange-rate database updating script will vary according to your operating system: cron on unix-like OSes or Scheduler on Win32.




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks again !

The method using offsite CSV files sounds reasonable.
But perhaps it would be wiser to have more than one single source?

I had a look to .
As I said I know nothing about rates .... so ( I'm gonna sound really dumb ) what is the calulation supposed to be for a conversion from Euros to Japanese Yens for exemple?
 
Sleidia:
A bank in a particular nation will give exchange rates from that nation's currency. I didn't know from which currency you needed exchange rates, as you had not specified this, so I posted a couple of off-hand links. Those aren't the only links on the entire internet providing that data. Find something more appropriate to your needs -- I gave you the Google search term you will need to find the sites that provide the information you want.

The European Central Bank (the ones responsible for managing the Euro) provide information exchanging Euros to other currencies in CSV. I know this because when I used the Google search term specified earlier, their page was one that came up.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 

How dumb I am ! ;)

I thought that the calculation was based on one main currency such as the dollar for exemple.

Well, money matters are my most weak point ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top