A handy tool to show stock pair properties in regarding correlation & cointegration
Table of Contents
I've put this utility together to help finding pair trade candidates, and to optimize model parameters.
Features:
- Run linear regression on stock pairs with correlation and display cointegration statistical properties
- Display historical stock pair relationship
- Quick & dirty backtesting for ratio and residual model trading strategies
- Correlation matrix for a universe of stocks - work in progress
With the current setup, the program download hourly and daily OHLC stock data from Interactive Broker API. Other data provider can be used, eg.: yahoo finance.
First step is to modify config.ini so it can match your setup: add IB API IP address and the path for your historical data directory
The technology used here is Bokeh. Run the application as a web service, change to the project root directory and execute the following command:
bokeh serve .
App starts and the UI is available on "http://localhost:5006/Bokeh_Gemini"
Using the application with ineractive brokers requires ib_insync library