The Juptyer Notebook contains the content and Python code for the four part series published on the blog of QuantInsti. An overview is provided of K-Means, an illustration is given of conducting pair selection without K-Means, a walkthrough of selecting the value for K is made, and a StatArb strategy is coded in Python using K-Means.
Fundamental features were used on the 505 stocks in the S&P 500. An Excel file has been included that provides the fundamental features of each stock in the index of which was used in this post.