Closed Tomasz-Ch closed 11 months ago
The data is not fetched dynamically, it is bundled with every release, by design. This is explained in the README:
Note that the currency converter does not query the API in real time, to avoid the overhead of the HTTP request. It uses embedded data in the library, which might not be up to date. If you need the latest data, please refer to the data section.
So if need the latest data, you can fetch it, then pass it to the object. This is an example of how to do this:
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)
Thank you for the code example, very helpful. Works!
I try to get actual currency rate (4.4653) for EUR/PLN, but the converter returns value 4.6343 from the date of last converter release (2023-09-28).
Using code for exact date
the answer is
RateNotFoundError: 2023-10-20 not in PLN bounds 1999-01-04/2023-09-28