# Pairs Trading: A Bayesian Example

Stefan Hollos and J. Richard Hollos

**Format and pricing:** Paperback (71 pages) $19.95, Kindle/pdf (71 pages) $9.99

**ISBN:** 9781887187152 (paperback), 9781887187114 (ebook)

**Publication date:** August 2012

Have you ever wondered whether Bayesian analysis can be applied toward the stock market? We did, and set out to investigate.

This 71 page book shows you how to find relationships between stocks or exchange traded funds (ETFs) using Bayesian analysis.

A relationship that most traders are probably familiar with is linear correlation. This is sometimes used as the basis for pairs trading. But linear correlation is just one way that stocks or ETFs can be related.

The analysis we present in this book can be used to exploit almost any kind of relationship that may exist between stocks or ETFs. The book will show how to calculate the probability of a stock or ETF ending the day up or down based on what other stocks or ETFs are doing.

A probability is more useful than a simple up or down signal. It quantifies the certainty of a prediction and allows a trader to take a position consistent with a given level of risk.

Any active trader should find the techniques presented in this book useful. We are only going to examine the relationships in one small group of ETFs as an example of what is possible but the same techniques will work for any set of stocks, ETFs, or even bonds.

The tool we use to calculate the probability of a positive or negative return on a stock or ETF is called a Bayesian classifier. It is called a classifier because it calculates probabilities for only two discrete outcomes: positive or negative.

The method we use to calculate these probabilities is called Bayes' Theorem.

In this book we not only show you the results of our analysis, but we show you HOW to do the analysis,... AND we give you the Bayesian classification software (available here) that we have developed FREE of charge. The software alone is worth several times that of this book.

#### About the authors

Stefan Hollos and J. Richard Hollos are physicists and electrical engineers by training, and enjoy anything related to math, physics, engineering and computing. They are brothers and business partners at Exstrom Laboratories LLC in Longmont, Colorado.

## Table of Contents

- Disclaimer
- Section 1
**Introduction** - Section 2
**Preparing the Data** - Section 3
**Visually Identifying the Classification Power of the Data** - Section 4
**Running class2kde** - 4.1
**From output probability to binary classification** - 4.2
**Classifying SPY with each of the other ETFs individually** - 4.2.1
**ROC curves for the other ETFs individually classifying SPY** - 4.2.2
**Statistics for the other ETFs individually classifying SPY** - 4.3
**Classifying SPY with pairs of the other ETFs** - 4.4
**Classifying SPY with 3 of the other ETFs** - 4.5
**Classifying SPY with 4 of the other ETFs** - 4.6
**Summary of results** - Section 5
**Using the Results for Trading** - Section 6
**Conclusions**

Send comments to: Richard Hollos (richard[AT]exstrom DOT com)

Copyright 2022 by Exstrom Laboratories LLC