A few observations.
Calculating the paired correlation seems extermely time consuming. There are something like 125K (sum(range(1,499)) unique stock pairs.
When looking at P/L results, it is important to look through various time periods. E.g. the whole range, 10 years, 5 years, 3 years, 1 year. This is important because if you avoid a downturn that is compounded forward. If you look two years later, after the downturn, the results may be lower. See
https://nderground-net.medium.com/the-twelve-percent-portfolio-682b03f70238
https://nderground-net.medium.com/stock-market-cash-trigger-a648510618d2