Skip to content

A project which performs a basic statistical arbitrage trading strategy based on the spread of two equites. Positions are opened and closed based on the period 15 lower Bollinger band.

Notifications You must be signed in to change notification settings

ALF28Dev/statistical_arbitrage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Statistical Arbitrage

I recently became interested in statistical arbitrage after reading the chapter about arbitrage in the book "Machine Learning For Algorithmic Trading". I have designed a basic strategy based on the correlation of two stocks. If two stocks have a high correlation, they are more likely to move in the same direction or the same patterns.

To profit from this strategy, we must track the spread between the stocks. We can trade the spread by buying and selling the stocks within the pair. An example spread is shown below with a bollinger band indicator.

Stat_Arb_Pairs

To identify pairs of stocks, I measured the level of correlation between two stock price time series. A basic scatter chart and linear regression are shown below, demonstrating a pair of stocks with a high correlation level.

Screenshot 2022-05-30 at 16 10 07

A key component of the statistical arbitrage strategy is knowing when to open and close positions. For my strategy, I chose to utilise a period 15 bollinger band. Whenever the spread drops below the lower band, I will open a position. The position will then be sold when the spread rises above the upper band. This strategy will only place long positions that profit when the spread widens (long bias).

Strategy Backtesting

Screenshot 2022-05-29 at 15 48 55

To test this strategy, I designed and developed my own backtest engine, which can take in data from the yfinance API and open/close trades as well as track/monitor positions and cumulative returns. The image above shows one of the output charts produced by my backtest engine. The entries and exits are clearly shown by the green (entries) and red (exits) triangles.

The cumulative returns of the strategy above are shown in the chart below. The system does not place a lot of trades; however it does seem to have a reasonably high win rate. I have also noticed that the win rate will increase dramatically based on the amount of correlation between the pairs. This becomes evident when using the strategy on Indices and DLC's.

Screenshot 2022-05-29 at 15 49 19

Index and DLC Statistical Arbitrage

Arbitrage using DLC'S

A DLC is a Dual-Listed Company. This is a company with a stock listed on more than one exchange. As exchanges are independent and markets are not perfect, price discrepancies will arise. A typical example of a dual-listed stock is GOOG and GOOGL. Below is the performance of my strategy on the GOOG and GOOGL pair. I have shown the spread, positions and returns of the backtest.

Screenshot 2022-05-30 at 21 33 25

Screenshot 2022-05-30 at 21 33 41

Screenshot 2022-05-30 at 21 33 51

Arbitrage using Indices

Indices are portfolios of stocks that move based on the portfolio's overall performance. Different indices can contain the same stocks. Therefore, they are likely to have the same performance over time. As indices have the same stocks, they have a high level of correlation, meaning it is potentially possible to profit when the indices diverge.

Furthur improvements

  • Research cointegration
  • Develop platform to manage statarb positions
  • Research sharpe ratios to measure performance

About

A project which performs a basic statistical arbitrage trading strategy based on the spread of two equites. Positions are opened and closed based on the period 15 lower Bollinger band.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages