J2897 icon

Dump Crypto Chart Data

J2897 | PRO | 10/03/21 04:59:13 PM UTC | 0 ⭐ | 8165 👁️ | Never ⏰ | []
Python |

540 B

|

None

|

0 👍

/

0 👎

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())
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎