Skip to Content
Hands-On Machine Learning for Algorithmic Trading
book

Hands-On Machine Learning for Algorithmic Trading

by Stefan Jansen
December 2018
Beginner to intermediate
684 pages
21h 9m
English
Packt Publishing
Content preview from Hands-On Machine Learning for Algorithmic Trading

How to prepare the data

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, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Machine Learning for Algorithmic Trading - Second Edition

Machine Learning for Algorithmic Trading - Second Edition

Stefan Jansen

Publisher Resources

ISBN: 9781789346411Supplemental Content