Advertisement
J2897

Dump Crypto Chart Data

Oct 3rd, 2021
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import yfinance as yf
  2. import csv
  3. from pathlib import PureWindowsPath
  4.  
  5. main_dir = r'C:\Users\J2897\Crypto'
  6. symbols_file = 'Top 30 Symbols.txt'
  7. symbols = csv.reader(open(PureWindowsPath(main_dir, symbols_file)))
  8. sub_dir = PureWindowsPath(main_dir, 'Chart Data')
  9.  
  10. for symbol in symbols:
  11.     # print(symbol[0])
  12.     symbol_csv = "{}.csv".format(symbol[0])
  13.     with open(PureWindowsPath(sub_dir, symbol_csv), 'w') as a_writer:
  14.         ticker = yf.Ticker(symbol[0])
  15.         df = ticker.history(period="1y")
  16.         a_writer.write(df.to_csv())
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement