import time
from urllib.request import urlretrieve
assets = ["GM","AAPL","KO"]
start_date = '2019-12-30'
end_date = '2020-01-03'
start_array = time.strptime(start_date,"%Y-%m-%d")
start_stamp = int(time.mktime(start_array))
end_array = time.strptime(end_date,"%Y-%m-%d")
end_stamp = int(time.mktime(end_array))
print(start_stamp,end_stamp)
start=str(start_stamp)
end=str(end_stamp)
print(start,end)
for asset in assets:
url = 'https://query1.finance.yahoo.com/v7/finance/download/'+ asset + '?period1='+ start +'&period2='+ end + '&interval=1d&events=history'
filename = asset + '.csv'
urlretrieve (url, filename)
time.sleep(1)