December 2018
Beginner to intermediate
684 pages
21h 9m
English
We load the Quandl adjusted stock price data (see the instructions on GitHub on how to obtain the source data) as follows (see the build_dataset notebook):
prices = (pd.read_hdf('../data/assets.h5', 'quandl/wiki/prices') .adj_close .unstack().loc['2007':])prices.info()DatetimeIndex: 2896 entries, 2007-01-01 to 2018-03-27Columns: 3199 entries, A to ZUMZ
We start by generating weekly returns for close to 2,500 stocks without missing data for the 2008-17 period, as follows:
returns = (prices .resample('W') .last() .pct_change() .loc['2008': '2017'] .dropna(axis=1) .sort_index(ascending=False))returns.info()DatetimeIndex: 522 entries, 2017-12-31 to 2008-01-06Columns: 2489 entries, A to ZUMZ
We'll use 52-week sequences, ...