Closed derekchased closed 6 months ago
The data shipped with the library is not dynamically updated. If you want to fetch the latest rates from the ECB, you need to download the latest data. You can do this operation once a day, as the data is only updated once a day.
import os.path as op
import urllib.request
from datetime import date
from currency_converter import ECB_URL, CurrencyConverter
filename = f"ecb_{date.today():%Y%m%d}.zip"
if not op.isfile(filename):
urllib.request.urlretrieve(ECB_URL, filename)
c = CurrencyConverter(filename)
We cannot receive a conversion for dates after 2023-6-26. We tried to convert a value from EUR to DKK for 11-28-23 and received the error:
currency_converter.currency_converter.RateNotFoundError: 2023-11-28 not in DKK bounds 1999-01-04/2023-06-26
{'USD': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'JPY': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'BGN': Bounds(first_date=datetime.date(2000, 7, 19), last_date=datetime.date(2023, 6, 26)), 'CZK': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'DKK': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'GBP': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'HUF': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'PLN': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'RON': Bounds(first_date=datetime.date(2005, 7, 1), last_date=datetime.date(2023, 6, 26)), 'SEK': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'CHF': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'ISK': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'NOK': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'TRY': Bounds(first_date=datetime.date(2005, 1, 3), last_date=datetime.date(2023, 6, 26)), 'AUD': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'BRL': Bounds(first_date=datetime.date(2008, 1, 2), last_date=datetime.date(2023, 6, 26)), 'CAD': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'CNY': Bounds(first_date=datetime.date(2005, 4, 1), last_date=datetime.date(2023, 6, 26)), 'HKD': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'IDR': Bounds(first_date=datetime.date(2005, 4, 1), last_date=datetime.date(2023, 6, 26)), 'ILS': Bounds(first_date=datetime.date(2011, 1, 3), last_date=datetime.date(2023, 6, 26)), 'INR': Bounds(first_date=datetime.date(2009, 1, 2), last_date=datetime.date(2023, 6, 26)), 'KRW': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'MXN': Bounds(first_date=datetime.date(2008, 1, 2), last_date=datetime.date(2023, 6, 26)), 'MYR': Bounds(first_date=datetime.date(2005, 4, 1), last_date=datetime.date(2023, 6, 26)), 'NZD': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'PHP': Bounds(first_date=datetime.date(2005, 4, 1), last_date=datetime.date(2023, 6, 26)), 'SGD': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'THB': Bounds(first_date=datetime.date(2005, 4, 1), last_date=datetime.date(2023, 6, 26)), 'ZAR': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26)), 'HRK': Bounds(first_date=datetime.date(2005, 4, 1), last_date=datetime.date(2022, 12, 30)), 'RUB': Bounds(first_date=datetime.date(2005, 4, 1), last_date=datetime.date(2022, 3, 1)), 'LTL': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2014, 12, 31)), 'LVL': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2013, 12, 31)), 'EEK': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2010, 12, 31)), 'SKK': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2008, 12, 31)), 'CYP': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2007, 12, 31)), 'MTL': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2007, 12, 31)), 'SIT': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2006, 12, 29)), 'ROL': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2005, 6, 30)), 'TRL': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2004, 12, 31)), 'EUR': Bounds(first_date=datetime.date(1999, 1, 4), last_date=datetime.date(2023, 6, 26))}