Use an alternate supplier of exchange rates, the New York Reserve.

CommentFileSizeAuthor
#3 235505_ver.patch1.83 KBaufumy
#1 235505.patch6.08 KBaufumy

Comments

aufumy’s picture

StatusFileSize
new6.08 KB

Initial draft of the patch, info on the New York Exchange web service:
http://www.newyorkfed.org/markets/pilotfx.html

kbahey’s picture

Version: master » 5.x-1.x-dev
Status: Needs review » Active

Audrey

Thank you so much for this. This is really helpful.

I committed it so that it is in 5.x-1.x-dev, and people can test it.

Couple of points:

1. Not sure if SOAP is available by default in all PHP or not. Can you verify, and add a check for it if it is not?

2. We need to also check that we are on PHP5, and refuse to do the NYFed thing if it is not, since SimpleXML is not in PHP4. This will be less of an issue in the future since Drupal 7 will be PHP5 only.

3. We can do a better job to abstract out each API (Yahoo, NYFed, ...etc.) in its own .inc (yahoo.inc, nyfed.inc ...), and have hooks in each that we call (e.g. get me the description, get me the currency list, do the exchange, ...etc.) This will make it far easier to integrate more sources in the future without over complicating code.

So, I will leave this one as active for now until the above are addressed.

aufumy’s picture

StatusFileSize
new1.83 KB

Hi Khalid

No problem.

This patch is against the latest cvs dev.
It checks that PHP version is greater than 4, otherwise do not show the option for selecting New York Federal rates.

I would like to modify the install file, to create a currency table, that will contain:
- currency codes
- description of currency codes
- symbol of the currency code
- whether each option supports this code

Would this address the need for #3 or is it completely different?

Thanks
Audrey

kbahey’s picture

I committed your patch, so that should take care of the PHP version.

As for #3, having a provider flag and a table is a good thing. I am thinking 3 tables to do this right.

1. {currency} with columns currency_code (CHAR(3)) and description
2. {provider} with provider_id and description as columns
3. {currency_provider} with a row for each currency that this provider supports, columns are provider_id and currency_code. We may even cache the last exchange rate in that table too, so we don't have to do lookups that often.

To get all currencies that a provider supports, table #3 will have that info right there if we filter by the provider.

I was thinking originally of a separate .inc file with hooks in it for each provider. The currency_api.module settings will scan for all the .inc files there and provide a list on which provider to choose. Then we store that provider ID and name in a variable, and we load the .inc in future calls using that saved info. All .inc will have two hooks, one for settings to return things specific to itself, and another to actually do the currency lookup. Make that 3, another to list currencies supported, if it is needed.

Look at hook_userpoints documentations in the README.txt under API section for 5.x-3.* of userpoints.

wisdom’s picture

Status: Closed (won't fix) » Active

It sounds New York Fed to discontinue service at the end of this year according to information on the linked site "The New York Fed announced its decision to discontinue the publication of foreign exchange rates on December 31, 2008."

While this is the case it is good to consider alternative besides Yahoo finance for currency conversion. Recently I found Yahoo Finance not providing current exchange rate in certain currencies. It is also not safe to depend on one currency conversion source specially, if one uses the currency module quite frequently. Is there other source which could be considered for inclusion?

kbahey’s picture

Status: Active » Closed (won't fix)

If this is true, then there is no point investing further in NY Fed.

I agree that having alternate sources is a good thing. If anyone finds them, please post a new issue, with the relevant info (currencies covered, frequency of updates, API specification, ...etc.).

I will revert back the changes for NY Fed in a few days unless we get new information.

Status: Active » Closed (won't fix)