Created
May 16, 2019 13:37
-
-
Save amitkot/8b51fba7043d392ccad7c6241557276a to your computer and use it in GitHub Desktop.
Print historic currency conversion rates #forex #python #util
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from forex_python.converter import CurrencyRates | |
def print_rates( | |
currency_from, | |
currency_to, | |
start_year, | |
start_month, | |
start_day, | |
days | |
): | |
c = CurrencyRates() | |
start = datetime.datetime(start_year, start_month, start_day) | |
for i in range(0, days + 1): | |
d = start + datetime.timedelta(days=i) | |
rate = c.get_rate(currency_from, currency_to, d) | |
print(f'{d.day}/{d.month}/{d.year}\t{rate}') | |
print_rates( | |
currency_from='USD', | |
currency_to='ILS', | |
start_year=2018, | |
start_month=6, | |
start_day=1, | |
days=35 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
forex-python==1.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment