13.08.2022 Views

advanced-algorithmic-trading

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 29

Supervised Learning for Intraday

Returns Prediction using QSTrader

All of the trading strategies discussed in the book so far using QSTrader have been carried out

on daily OHLCV "bar" equities data. In this chapter an intraday strategy is backtested. A

predictive machine learning based algorithm is outlined and implemented, which attempts to

predict directional changes of minutely equities returns.

The chapter begins with a discussion of prediction goals for asset pricing data and the issues

associated with classification class imbalance, which is a common situation in quantitative finance

returns prediction.

Attention then turns towards building a predictive model using the Python Scikit-Learn

library with a variety of machine learning based classifiers. Certain convenience functions are

presented that aid such models in an intraday "online" environment.

The implementation of a Strategy class and Backtest script is presented that provides

the full code for testing such a predictive model. The code is relatively straightforward and

encourages significant experimentation through parameter tweaking and modification of the asset

universe.

Finally backtested results are presented for a particular statistical ensemeble technique–the

Random Forest classifier–on an individual equity, AREX, for the period 2013-2014, trained on

data from 2007-2012.

Note that the full code is presented at the end of the chapter. It requires a working installation

of the latest version of QSTrader, which can be found at the Github project page.

29.1 Prediction Goals with Machine Learning

In this chapter the main focus is on using supervised machine learning to make predictions about

asset price directional changes. These methods have been covered before on QuantStart.com and

in previous books, but they have not been placed into a robust intraday event-driven backtest

system as of yet. This chapter changes that.

The first task is to determine exactly what is being predicted. There are a few of examples

to consider:

• Direction - Predict the directional change of the returns of an equity in the next bar

419

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!