forex-python icon indicating copy to clipboard operation
forex-python copied to clipboard

CurrencyRates conversion is not correct.

Open muhammad-grayphite opened this issue 2 years ago • 2 comments

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

muhammad-grayphite avatar Jul 24 '23 08:07 muhammad-grayphite

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

Cruuncher avatar Aug 02 '23 19:08 Cruuncher

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

janosspaits avatar Aug 25 '23 16:08 janosspaits