MicroPyramid / forex-python

Foreign exchange rates, Bitcoin price index and currency conversion using ratesapi.io
http://forex-python.readthedocs.io/en/latest/usage.html
MIT License
661 stars 195 forks source link

CurrencyRates conversion is not correct. #138

Open muhammad-grayphite opened 1 year ago

muhammad-grayphite commented 1 year ago

I have a usecase where I am converting VND to USD but conversion rate are not valid. for example:

Screenshot 2023-07-24 at 1 31 35 PM Screenshot 2023-07-24 at 1 31 50 PM

These values are not even close. if library is not supporting this currency than it should not convert. please let me know if this can be fixed. I need an API/Library which can convert all the currencies to usd even the local currencies. like Google finance

Cruuncher commented 1 year ago

Going from VND to USD I get an error, not a number:

Python 3.11.4 (main, Jun 20 2023, 16:59:59) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from forex_python.converter import CurrencyRates
>>> c = CurrencyRates()
>>> c.convert('VND', 'USD', 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/forex_python/converter.py", line 108, in convert
    raise RatesNotAvailableError("Currency Rates Source Not Ready")
forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Ready
janosspaits commented 1 year ago

I have noticed the same thing today with GBP to EUR. It broke yesterday. 2 days ago it was the correct 1.16, now it's 0.126 or something which is completely off.

from forex_python.converter import *
from datetime import datetime, timedelta

yesterday = datetime.now() - timedelta(days=1)
now = datetime.now()
c = CurrencyRates()
start_currency='GBP'
end_currency='EUR'
money = 1.0
result = c.get_rate(base_cur=start_currency, dest_cur=end_currency, date_obj=yesterday) * money

print(result)

this prints out 0.13268758707622902

even more interestingly if you use convert instead of get_rate, it gets you the correct amount