Created
May 11, 2021 16:06
-
-
Save fnneves/31c6f74004b922e5ad77c2b1e75c37fc to your computer and use it in GitHub Desktop.
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
ly = datetime.today().year-1 | |
today = datetime.today() | |
start_sp = datetime(2019, 1, 1) | |
end_sp = today | |
start_stocks = datetime(2019, 1, 1) | |
end_stocks = today | |
start_ytd = datetime(ly, 12, 31) + BDay(1) | |
def get(tickers, startdate, enddate): | |
def data(ticker): | |
return (pdr.get_data_yahoo(ticker, start=startdate, end=enddate)) | |
datas = map(data, tickers) | |
return(pd.concat(datas, keys=tickers, names=['ticker', 'date'])) | |
all_data = get(filt_tickers, start_stocks, end_stocks) | |
clean_header(all_data) | |
# saving all stock prices individually to the specified folder | |
for tick in filt_tickers: | |
all_data.loc[tick].to_csv('../outputs/price_hist/{}_price_hist.csv'.format(tick)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment