Skip to content

Instantly share code, notes, and snippets.

@madeleine68
Created December 29, 2020 00:35
Show Gist options
  • Save madeleine68/44a70be79433dfd62b5050a402ae9be4 to your computer and use it in GitHub Desktop.
Save madeleine68/44a70be79433dfd62b5050a402ae9be4 to your computer and use it in GitHub Desktop.
start = dt.datetime(20XX, 1, 1)
end = dt.datetime.now()
for ticker in tickers:
if not os.path.exists('stock_dfs/{}.csv'.format(ticker)):
df = pdr.DataReader(ticker.replace('.', '-'), 'yahoo', start, end)
df.reset_index(inplace=True)
df.set_index("Date", inplace=True)
df.to_csv('stock_dfs/{}.csv'.format(ticker))
else:
print('Already have {}'.format(ticker))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment