You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unusual exchange rates that are actually incorrect #107
from forex_python import CurrencyRates
c = CurrencyRates()
rates = []
for val in df['date']:
dt = datetime.strptime(val, '%Y-%m-%d %H:%M:%S')
rate = c.get_rate('USD', 'RUB', dt)
rates.append(rate)
And while we're at it, could you please comment: can I pass a list of dates to the api call? Because it takes a lot of time to make even 10 api calls. Some of my datasets have tens of thousands of rows with datetime values. It will take forever to parse them one by one as in the code above
IMO the problem is still existing in the following form of being an outlier:
CurrencyRates().get_rate("EUR", "RON", datetime.date(2022, 4, 4)) returns 5.597789077041813, which is not correct.
I've used the 2 APIs for validation:
https://theforexapi.com/api/2022-04-04?base=EUR: it returns actually "RON":4.9432 (the closes to the reality)
https://api.exchangeratesapi.io/ API which returns "rate": 4.942597,
and the latter is much closer to the correct result compared to this Python lib (while not the most precise one): to validate all I've looked up on https://www.exchangerates.org.uk/EUR-RON-spot-exchange-rates-history-2022.html and it returns €1 EUR = lei4.9435
Activity
uwesimm commentedon Feb 18, 2022
actually the problem is with the underlying api itself:
uwe@air-uwe xxx % curl 'https://theforexapi.com/api/2021-06-01/?base=USD&symbols=EUR'
{"date":"2021-06-01","base":"USD","rates":{"EUR":0.8179959100204499}}%
uwe@air-uwe xxx % curl 'https://theforexapi.com/api/2021-06-01/?base=USD&symbols=EUR'
{"date":"2022-02-04","base":"USD","rates":{"EUR":0.8722958827634333}}%
as you can see even a curl returns the wrong rate for the wrong date. so it is an issue of the underlying service
ashwin31 commentedon Aug 7, 2022
@uwesimm the underlying api got fixed and returining consistent data.
ashwin31 commentedon Aug 7, 2022
@DanilZherebtsov we can't post multiple dates at once. I will see how to improve performance. I will implement some caching and get back to you.
portikCoder commentedon Apr 22, 2023
IMO the problem is still existing in the following form of being an outlier:
CurrencyRates().get_rate("EUR", "RON", datetime.date(2022, 4, 4))returns 5.597789077041813, which is not correct.I've used the 2 APIs for validation:
https://theforexapi.com/api/2022-04-04?base=EUR: it returns actually"RON":4.9432(the closes to the reality)https://api.exchangeratesapi.io/API which returns"rate": 4.942597,and the latter is much closer to the correct result compared to this Python lib (while not the most precise one): to validate all I've looked up on https://www.exchangerates.org.uk/EUR-RON-spot-exchange-rates-history-2022.html and it returns
€1 EUR = lei4.9435CAVEAT:
lei == RON