kniklas / get-fx

Get FX is tool to download average FX rates from National Bank of Poland (NBP)
Other
0 stars 0 forks source link

Support fx rate between any two currencies #11

Open binarysailor opened 3 years ago

binarysailor commented 3 years ago

Currently it's only possible to get FX of a single currency to PLN (at least as long as the NBP service is used).

I think an option to get an FX from any A currency to any B currency could be a useful feature. This, of course, can be calculated based on A's and B's rates to a common "base" currency, regardless of what the base currency actually is:

A / B = (A / BASE) / (B / BASE)

The command line could for example support this with an additional optional currency argument directly following the current one, eg: getfx USD - behaves just like currently, ie. gets USD / PLN rate getfx USD EUR - gets USD / EUR rate

In other words, the general command format would be: getfx <CURR1> [CURR2] [options] - returns the FX rate of CURR1 to CURR2. If CURR2 is not specified, then it is assumed to be the "base" currency (PLN in case of NBP).

kniklas commented 3 years ago

Thank you @binarysailor for your thoughts! I have been thinking about adding in the future wrapper classes (go GetFX) for other FX providers (e.g. Forex API or hook it to DNB Nord API) and these providers can provide FX rates for any currency pair. These FXes are valid in specific context- i.e if you wish to check Forex FX (and compare to bank FX to check spread) or get FX rate provided by DNB Nord if you work in Norway and you wish to transfer monies from Norway to Poland / other country).

Initial idea for GetFX app was to easily get currency exchange (to PLN) from NBP and use this data (FX rate, table and date) for accounting purposes, as finding this information at NBP web page requires several clicks and is a bit cumbersome.

Not sure if result from your equation will give similar result as from Forex - if it is similar then it might be an interesting alternative to Forex API (example provider: https://fixer.io)!

Anyways - thank you for your idea, I think in the future it is worth to consider conversion from any currency to any currency - when this feature will be implemented we should look at available options of programming this.