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.

385

By definition a mean-reverting series will occasionally deviate from its mean and then eventually

revert. Bollinger Bands provide a mechanism for entering and exiting trades by employing

standard deviation "thresholds" at which trades can be entered into and exited from.

To generate trades the first task is to calculate a z-score (also known as a standard score)

of the current latest spread price. This is achieved by taking the latest portfolio market price,

subtracting the rolling mean and dividing by the rolling standard deviation.

Once this z-score is calculated a position will be opened or closed out under the following

conditions:

• z score < −z entry : Long entry

• z score > +z entry : Short entry

• z score ≥ −z exit : Long close

• z score ≤ +z exit : Short close

Where z score is the latest standardised spread price, z entry is the trade entry threshold and

z exit is the trade exit threshold.

A long position here means purchasing one share of ARNC and shorting 1.213 shares of UNG.

Clearly it is impossible to trade a fractional number of shares. Hence such a fraction is rounded

to the nearest integer when multiplied by a large unit base quantity, e.g. 10,000 "units" of the

portfolio traded.

Thus profitable trades are likely to occur assuming that the above conditions are regularly

met, which a cointegrating pair with high volatility should provide.

For this particular strategy the lookback period used for the rolling moving average and the

rolling standard deviation is equal to 15 bars. z entry = 1.5, while z exit = 0.5. All of these

parameters are arbitrarily picked for this chapter, but a full research project would optimise

these via some form of parameter grid-search.

27.4 Data

In order to carry out this strategy it is necessary to have daily OHLCV pricing data for the

equities and ETFs in the period covered by this backtest. Table 27.4 outlines the required asset

prices.

Ticker Name Period Link

ARNC Arconic Inc. (prev

Alcoa Inc.)

11th November 2014

- 1st September 2016

Yahoo Finance

UNG

United States Natu-

11th November 2014

Yahoo Finance

ral Gas ETF

- 1st September 2016

This data will need to placed in the directory specified by the QSTrader settings file if you

wish to replicate the results.

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

Saved successfully!

Ooh no, something went wrong!