billthefarmer / currency

Android currency conversion
https://billthefarmer.github.io/currency
GNU General Public License v3.0
86 stars 32 forks source link

Need to add all the other currencies #17

Closed mexon closed 6 years ago

mexon commented 7 years ago

Just 32 currencies is a very myopic view of the world. You're excluding all those people who live off the major plane routes - and those who want to be friends with them. F-droid doesn't seem to have any currency converter with reasonable coverage of the world. This is a sad reflection on the open source community.

There must be somewhere this data could be scraped, for example the IMF. It doesn't necessarily need to be bang up-to-date. Please try to make this app more useful for a world traveller.

billthefarmer commented 7 years ago

Perhaps you should let the ECB know about their myopic view of the world.

You are just the latest to complain about the currencies available in this app. I have had various suggestions of data sources, none of which turned out to be free. I had already looked at the Bank of England and the Federal Reserve, which both offer fewer currencies. The advantage of using the ECB data is that it uses the ISO 4217 currency codes, and is in industry standard XML, which makes it simple to parse using a standard XML parser.

<?xml version="1.0" encoding="UTF-8"?>
<gesmes:Envelope
    xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01"
    xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
  <gesmes:subject>Reference rates</gesmes:subject>
  <gesmes:Sender>
    <gesmes:name>European Central Bank</gesmes:name>
  </gesmes:Sender>
  <Cube>
    <Cube time='2016-11-25'>
      <Cube currency='USD' rate='1.0592'/>
      <Cube currency='JPY' rate='119.73'/>
      <Cube currency='BGN' rate='1.9558'/>
      <Cube currency='CZK' rate='27.039'/>
      <Cube currency='DKK' rate='7.4380'/>
      <Cube currency='GBP' rate='0.85182'/>
      <Cube currency='HUF' rate='309.33'/>
      <Cube currency='PLN' rate='4.4190'/>
      <Cube currency='RON' rate='4.5140'/>
      <Cube currency='SEK' rate='9.7840'/>
      <Cube currency='CHF' rate='1.0736'/>
      <Cube currency='NOK' rate='9.0690'/>
      <Cube currency='HRK' rate='7.5318'/>
      <Cube currency='RUB' rate='68.4111'/>
      <Cube currency='TRY' rate='3.6523'/>
      <Cube currency='AUD' rate='1.4230'/>
      <Cube currency='BRL' rate='3.6394'/>
      <Cube currency='CAD' rate='1.4290'/>
      <Cube currency='CNY' rate='7.3295'/>
      <Cube currency='HKD' rate='8.2153'/>
      <Cube currency='IDR' rate='14317.74'/>
      <Cube currency='ILS' rate='4.1047'/>
      <Cube currency='INR' rate='72.5925'/>
      <Cube currency='KRW' rate='1247.03'/>
      <Cube currency='MXN' rate='21.8727'/>
      <Cube currency='MYR' rate='4.7203'/>
      <Cube currency='NZD' rate='1.5040'/>
      <Cube currency='PHP' rate='52.801'/>
      <Cube currency='SGD' rate='1.5132'/>
      <Cube currency='THB' rate='37.760'/>
      <Cube currency='ZAR' rate='14.9718'/>
    </Cube>
  </Cube>
</gesmes:Envelope>

The IMF do offer currency rates, but it is in tab delimited spreadsheet format aimed at yuppies, and uses somewhat idiosyncratic currency names in some instances. And some of the currencies are not reported.

Representative Exchange Rates for Selected Currencies
29-Sep-17
Last Updated: 16:23:35, US Eastern Standard Time
Chinese Yuan        6.64810000
Euro    1   1.18060000
Japanese Yen        112.66000000
U.K. Pound Sterling 1   1.33840000
U.S. Dollar     1.00000000
Algerian Dinar      113.12060000
Australian Dollar   1   00.78390000
Bahrain Dinar       00.37600000
Botswana Pula   1   00.09730000
Brazilian Real      3.18650000
Brunei Dollar       1.35840000
Canadian Dollar     1.24800000
Chilean Peso        636.85000000
Colombian Peso      2,941.07000000
Czech Koruna        22.00300000
Danish Krone        6.30380000
Hungarian Forint        263.75000000
Icelandic Krona     105.47000000
Indian Rupee        65.35520000
Indonesian Rupiah       13,492.00000000
Iranian Rial        ---
Israeli New Sheqel      ---
Kazakhstani Tenge       341.19000000
Korean Won      1,146.70000000
Kuwaiti Dinar       00.30215000
Libyan Dinar    2   1.93240000
Malaysian Ringgit       4.22750000
Mauritian Rupee     33.82450000
Mexican Peso        18.15900000
Nepalese Rupee      ---
New Zealand Dollar  1   00.72210000
Norwegian Krone     7.97260000
Rial Omani      00.38450000
Pakistani Rupee     105.42220000
Nuevo Sol       ---
Philippine Peso     51.07300000
Polish Zloty        3.65190000
Qatar Riyal     3.64000000
Russian Ruble       58.01690000
Saudi Arabian Riyal     3.75000000
Singapore Dollar        1.35840000
South African Rand      13.49910000
Sri Lanka Rupee     153.09830000
Swedish Krona       8.10860000
Swiss Franc     00.96940000
Thai Baht       33.36900000
Trinidad And Tobago Dollar      6.75290000
Tunisian Dinar      2.47647000
U.A.E. Dirham       3.67250000
Peso Uruguayo       ---
Bolivar Fuerte      9.97500000
Notes:

These representative exchange rates, which are reported to the Fund by the issuing central bank, are expressed in terms of currency units per U.S. dollar, except for those indicated by

(1) which are in terms of U.S. dollars per currency unit, and those indicated by

(2) which are expressed in terms of currency units per SDR.

To parse this requires a homebrew parser, with no guarantee that the idiosyncratic names won't change, breaking the parser. I will try it and see if it works

billthefarmer commented 7 years ago

Well I started to test my parser and got this:

10-02 15:55:28.329 26336 26362 D Data    : Representative Exchange Rates for Selected Currencies
10-02 15:55:28.330 26336 26362 D Data    : 02-Oct-17
10-02 15:55:28.330 26336 26362 D Data    : Last Updated: 10:28:57, US Eastern Standard Time
10-02 15:55:28.331 26336 26362 D Data    : Chinese Yuan         ---
10-02 15:55:28.331 26336 26362 D Data    : Euro 1       1.17440000
10-02 15:55:28.332 26336 26362 D Data    : Euro/0.8514986376021798
10-02 15:55:28.332 26336 26362 D Data    : Japanese Yen         112.76000000
10-02 15:55:28.332 26336 26362 D Data    : Japanese Yen/112.76
10-02 15:55:28.332 26336 26362 D Data    : U.K. Pound Sterling  1       1.33105000
10-02 15:55:28.333 26336 26362 D Data    : U.K. Pound Sterling/0.7512865782652792
10-02 15:55:28.333 26336 26362 D Data    : U.S. Dollar          1.00000000
10-02 15:55:28.333 26336 26362 D Data    : U.S. Dollar/1.0
10-02 15:55:28.333 26336 26362 D Data    : Algerian Dinar               ---
10-02 15:55:28.333 26336 26362 D Data    : Australian Dollar    1       ---
10-02 15:55:28.334 26336 26362 D Data    : Bahrain Dinar                ---
10-02 15:55:28.334 26336 26362 D Data    : Botswana Pula        1       ---
10-02 15:55:28.334 26336 26362 D Data    : Brazilian Real               ---
10-02 15:55:28.335 26336 26362 D Data    : Brunei Dollar                ---
10-02 15:55:28.335 26336 26362 D Data    : Canadian Dollar              ---
10-02 15:55:28.335 26336 26362 D Data    : Chilean Peso         ---
10-02 15:55:28.337 26336 26362 D Data    : Colombian Peso               ---
10-02 15:55:28.337 26336 26362 D Data    : Czech Koruna         ---
10-02 15:55:28.337 26336 26362 D Data    : Danish Krone         ---
10-02 15:55:28.338 26336 26362 D Data    : Hungarian Forint             ---
10-02 15:55:28.338 26336 26362 D Data    : Icelandic Krona              ---
10-02 15:55:28.339 26336 26362 D Data    : Indian Rupee         ---
10-02 15:55:28.340 26336 26362 D Data    : Indonesian Rupiah            ---
10-02 15:55:28.340 26336 26362 D Data    : Iranian Rial         ---
10-02 15:55:28.340 26336 26362 D Data    : Israeli New Sheqel           ---
10-02 15:55:28.341 26336 26362 D Data    : Kazakhstani Tenge            ---
10-02 15:55:28.341 26336 26362 D Data    : Korean Won           ---
10-02 15:55:28.342 26336 26362 D Data    : Kuwaiti Dinar                ---
10-02 15:55:28.342 26336 26362 D Data    : Libyan Dinar 2       ---
10-02 15:55:28.343 26336 26362 D Data    : Malaysian Ringgit            ---
10-02 15:55:28.343 26336 26362 D Data    : Mauritian Rupee              ---
10-02 15:55:28.344 26336 26362 D Data    : Mexican Peso         ---
10-02 15:55:28.345 26336 26362 D Data    : Nepalese Rupee               ---
10-02 15:55:28.345 26336 26362 D Data    : New Zealand Dollar   1       ---
10-02 15:55:28.345 26336 26362 D Data    : Norwegian Krone              ---
10-02 15:55:28.346 26336 26362 D Data    : Rial Omani           ---
10-02 15:55:28.346 26336 26362 D Data    : Pakistani Rupee              ---
10-02 15:55:28.346 26336 26362 D Data    : Nuevo Sol            ---
10-02 15:55:28.347 26336 26362 D Data    : Philippine Peso              ---
10-02 15:55:28.347 26336 26362 D Data    : Polish Zloty         ---
10-02 15:55:28.348 26336 26362 D Data    : Qatar Riyal          ---
10-02 15:55:28.348 26336 26362 D Data    : Russian Ruble                ---
10-02 15:55:28.349 26336 26362 D Data    : Saudi Arabian Riyal          ---
10-02 15:55:28.349 26336 26362 D Data    : Singapore Dollar             ---
10-02 15:55:28.349 26336 26362 D Data    : South African Rand           ---
10-02 15:55:28.350 26336 26362 D Data    : Sri Lanka Rupee              ---
10-02 15:55:28.350 26336 26362 D Data    : Swedish Krona                ---
10-02 15:55:28.350 26336 26362 D Data    : Swiss Franc          ---
10-02 15:55:28.351 26336 26362 D Data    : Thai Baht            ---
10-02 15:55:28.351 26336 26362 D Data    : Trinidad And Tobago Dollar           ---
10-02 15:55:28.351 26336 26362 D Data    : Tunisian Dinar               ---
10-02 15:55:28.352 26336 26362 D Data    : U.A.E. Dirham                ---
10-02 15:55:28.352 26336 26362 D Data    : Peso Uruguayo                ---
10-02 15:55:28.353 26336 26362 D Data    : Bolivar Fuerte               ---
10-02 15:55:28.353 26336 26362 D Data    : Notes:
10-02 15:55:28.353 26336 26362 D Data    :
10-02 15:55:28.354 26336 26362 D Data    :
10-02 15:55:28.354 26336 26362 D Data    : These representative exchange rates, which are reported to the Fund by the issuing central bank, are expressed in terms of currency units per U.S. dollar, except for those indicated by
10-02 15:55:28.354 26336 26362 D Data    :
10-02 15:55:28.354 26336 26362 D Data    : (1) which are in terms of U.S. dollars per currency unit, and those indicated by
10-02 15:55:28.355 26336 26362 D Data    :
10-02 15:55:28.355 26336 26362 D Data    : (2) which are expressed in terms of currency units per SDR.

At that point I decided I'm wasting my time. Try XE Currency, it's where I got the idea for this app.

simonfrey commented 7 years ago

Is send the IMF team a message regarding the XML issue. Hopefully they will responde and help us out with this issue. Would love to see more currencys 👍

--- Message (Replace my real name with L1am0)--- **Dear Sir or Madame,

would it be possible to also provide the Exchange Rate Data as XML? (Regarding this data: http://www.imf.org/external/np/fin/data/rms_rep.aspx)

The TSV does work with Excel/Libre Office but is very hard to automaticaly parse for usage in Software.

The ECB does provide a quite nice XML format:

Would be so awesome if you could adapt a similar format and provide the data in that way.

Thanks a lot, L1am0

p.S. We would love to use your data as source for the open source currency converter (https://f-droid.org/packages/org.billthefarmer.currency/). Would help even more people with having more exchanges rates.**

mexon commented 7 years ago

There's this one:

https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote

But then I only found that from this link, which enjoys pointing out that it involves breaking Yahoo's terms of service:

https://stackoverflow.com/questions/5108399/yahoo-finance-all-currencies-quote-api-documentation

That link is 4 years old and apparently Yahoo haven't got around to turning it off yet. Is anyone actually at home at Yahoo these days?

mexon commented 7 years ago

Yahoo's YQL system does seem to have the data. But you need to switch on "community tables", and I haven't figured out if that's possible via the REST API:

http://developer.yahoo.com/yql/console/?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22EURMNT%22%2C%22LKRUSD%22)&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

simonfrey commented 7 years ago

I started working on a meta api for this issue. The new api will combine several other ones and will provide the data as XML and JSON.

I will keep you guys informed about the process.

Any special wishes for the api?

simonfrey commented 7 years ago

Hey guys,

the meta api is up and running 👍 It currently supports 94 currencies and scrapes from ECB, IMF, FX The rates are rescraped based on the different sources and the data is parsed out from the database every 5 minutes. So the data is between 5 minutes and 24 hours old.

It supports two formats XML & JSON.

You can access the api via the following url: XML: https://api.currex.info/xml/latest/EUR/ JSON: https://api.currex.info/json/latest/EUR/

The last parameter is the base currency. All 94 urrencies are supported as base currency. (But it thought to stick to the current version in the app EUR would be best as base)

Every currency has a Unix timestamp attached, to know their age. The data gathering follows the princible "better old data, than none". So if the scraping of a sources fails, the api sticks to the older dataset. (IMF gave me quite some headache with that ;))

Right now there is only the "latest" feature included with historic data hopefully follwing in the next 1.5 month.

I am still working on a website and an in depth documentation, but would love to get feedback from you :D

It's a be free, use free model. So you can use the api without any costs or constrains.

Looking forward for your feedback, L1am0

billthefarmer commented 7 years ago

It's a good idea, but it introduces an unknown dependency. At the moment the app is solely dependent on the ECB and they aren't going anywhere anytime soon. If I use your API, I don't know how reliable it is or whether it may disappear at any time. And the whois record doesn't inspire confidence:

Registered to Super Man
Email superman@trash-mail.com
Registrar Key-Systems GmbH
Name Servers ns5.speicherzentrum.de ns4.speicherzentrum.de

Two things - What's the FX data source and I looked at your web page where you talk about using PHP for a blog. I can recommend Hugo for that - see my blog. It's all under your control, you can have live updates while you edit the source and then just post it when done.

simonfrey commented 7 years ago

The FX data source: http://www.fx-exchange.com/

The API has some sort of trust model: The sources get rated and only the best one is used. (E.g. EUR comes from the ECB even when FX has more recent data.)

My domain register does not provide whois privacy and I am sick of getting my inbox flooded with spam mail. That's why there is this data.

Offtopic Blog: During setting up the l1am0.eu HP I thought about writing blog articles and setup that markdown php system. But I am to ocupied by other stuff and don't enjoy writing that much. So that Blog is kinda dead.

I am using Hugo right now for another project and I don't like it. I depend on inserting video and image gallerys and that works quite bad and is a lot of work. Will be back to WP the next time ;)

ilf commented 6 years ago

Unfortunately, I am not able to name a good free data source, but I do want to thank the creators of this App for their initiative and also underline the importance of more currencies. I am currently travelling and could/would really use this, but unfortunately, it's missing the countries I am in. Best!

billthefarmer commented 6 years ago

I have decided that trying to add more currencies from disparate sources makes this app far too complicated. It was designed around the current and historical data freely and reliably available from the ECB and to redesign it to deal with currencies that have historical data, currencies that don't, data sources that might disappear and other potential pitfalls that I haven't found yet makes it far too complex.

quassy commented 6 years ago

How about you worked with Fixer? It looks like it supports quite a lot of currencies. They seem to pool various source to get there data, you'd only have to cache the API requests otherwise 1000 could be reached quite quickly.

billthefarmer commented 6 years ago

I think I looked at this or a similar service before. I have no idea how many copies of my app are out there, so a limit on the usage is not acceptable. Caching the data would require setting up a site to do it and supporting it.

alexanderadam commented 6 years ago

Regarding Fixer: what if those Fixer currencies will just be enabled when a user adds an own API key in the settings?

This way every user would have his own 1'000 calls per month which sounds like more than enough.

billthefarmer commented 6 years ago

Every time this issue comes up I investigate and find that it's a non free source or rate limited. For example the unofficial Yahoo source that some were using has been discontinued, probably because it was being abused, the source Equate is using for cryptocurrencies appears to be free and not limited currently, but is due to be rate limited soon according to their docs page.

Anyone who feels up to the challenge is free to fork this app and produce a more comprehensive version, but I think it will be a full time job keeping it working and chasing data sources as they change. I've got a dozen other FOSS apps and libraries to keep track of plus other projects.

SecT0uch commented 5 years ago

Actually, @alexanderadam proposed a good idea. Unfortunately, I donnt know how to develop for Android