Skip to content

Instantly share code, notes, and snippets.

@amitkot
Created May 16, 2019 13:37
Show Gist options
  • Save amitkot/8b51fba7043d392ccad7c6241557276a to your computer and use it in GitHub Desktop.
Save amitkot/8b51fba7043d392ccad7c6241557276a to your computer and use it in GitHub Desktop.
Print historic currency conversion rates #forex #python #util
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
)
forex-python==1.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment