Closed jesusignazio closed 2 years ago
The default date used is the latest date available in the data. The data used by default is embedded within the library, so the date you see is tied to the latest release. If you want to have more recent data, you have to download it from the European Central Bank, then pass the corresponding path to the constructor (look for details in the README). The data is refreshed once a day, so you only really need to download it once a day. In Python, downloading it looks like 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)
If you use the command-line, this should work (-f to specify the data source):
$ wget https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.zip -O latest.zip
$ currency_converter 1 EUR --to GBP -f latest.zip
1.000 EUR = 0.846 GBP on 2022-07-14
By the moment of writing this issue, date is 2022-07-13, but if I use the library without specifying date, it takes a value from more than two months ago:
I think it should take current date is no data is provided.