Open DanilZherebtsov opened 2 years ago
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
@uwesimm the underlying api got fixed and returining consistent data.
@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.
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
CAVEAT: lei == RON
forex_python returns incorrect exchange rates for some dates
print(rates)
[27.567811307665625, 28.92096528834186, 28.919594500763782, 28.990549527476368, 76.28786342123057, <--- incorrect 29.580679480814247, 26.931377115354756, 27.043069694596714, 76.15971737613398, <--- incorrect 76.15971737613398] <--- incorrectAnd 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