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

Univariate time series regression

In this subsection, we will forecast the S&P 500 Index values (see the univariate_time_series_regression notebook for implementation details).

We obtain data for 2010-2018 from the Federal Reserved Bank's Data Service (FRED—see Chapter 2, Market and Fundamental Data), as follows:

sp500 = web.DataReader('SP500', 'fred', start='2010',                         end='2019').dropna()sp500.info()DatetimeIndex: 2264 entries, 2010-01-04 to 2018-12-31
Data columns (total 1 columns):
SP500    2264 non-null float64

We process the data by scaling it to the [0, 1] interval using scikit-learn's minmax_scale function, as shown here:

from sklearn.preprocessing import minmax_scalesp500_scaled = sp500.apply(minmax_scale)
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