Last active
March 4, 2021 07:42
-
-
Save pyykkis/1383eedac0e0e573a73f2150abf0bd73 to your computer and use it in GitHub Desktop.
Download 1 year history of all Nasdaq traded companies for market analysis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import pandas as pd | |
import yfinance as yf | |
symbols = pd.read_csv('ftp://ftp.nasdaqtrader.com/symboldirectory/nasdaqtraded.txt', delimiter='|') | |
# Excluded symbols: | |
# - Test symbols | |
# - ETFs | |
# - Financial status: Other than Normal | |
# - Last row (file timestamp) | |
symbols = symbols[(symbols['Test Issue'] == 'N') & (symbols['ETF'] == 'N') & (symbols['Financial Status'] == 'N') ][:-1] | |
n = 360 # Download 1 year history | |
now = datetime.datetime.now() | |
start = now - datetime.timedelta(days = n) | |
data = yf.download(symbols['Symbol'].tolist(), start=start, threads=True, group_by='ticker', interval='1d') | |
data.to_parquet(f'data/nasdaq.parquet') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment