Algotrading101 blog
What trading assets work the best together to form a trading pair for the Pairs Trading strategy?
Pairs trading is a strategy in which a trader buys one asset while shorting another. The main premise of the trade is that when the two pairs diverge, they will likely converge again resulting in profit for the trader.
I categorized this problem as a clustering unsupervised machine learning task.
The structure of the code and the problem-solving is made up of the following steps:
- Obtain all the S&P 500 stock from Yahoo Finance
- Clean and prepare the data (treat missing values, calculate volatility, scale the date, etc.)
- Fit three Machine Learning Models to the data and explore their outputs a) k-Means Clustering b) Hierarchical Clustering c) Affinity Propagation Clustering
- Compare the models by their silhouette score and pick the best one
- Extract the Trading Pairs a) Do a cointegration test on clusters to find the best pairs b) Plot the Pairs
For a more detailed Guide behind the process please visit the Algotrading101 blog post: https://algotrading101.com/learn/cluster-analysis-guide/
Author | Igor Radovanovic |
---|---|
Published | May 14, 2021 |