Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import yfinance as yf
- import csv
- from pathlib import PureWindowsPath
- main_dir = r'C:\Users\J2897\Crypto'
- symbols_file = 'Top 30 Symbols.txt'
- symbols = csv.reader(open(PureWindowsPath(main_dir, symbols_file)))
- sub_dir = PureWindowsPath(main_dir, 'Chart Data')
- for symbol in symbols:
- # print(symbol[0])
- symbol_csv = "{}.csv".format(symbol[0])
- with open(PureWindowsPath(sub_dir, symbol_csv), 'w') as a_writer:
- ticker = yf.Ticker(symbol[0])
- df = ticker.history(period="1y")
- a_writer.write(df.to_csv())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement