It's no coincidence that investors are getting more positive on the stock market as the yield curve has been steepening.

Bank of America Merrill Lynch's quantitative team has found a direct relation between the move in stock prices and the yield curve, and some sectors, like energy, financials and materials, are far more correlated than others. A steepening yield curve is a positive sign for growth, and those sectors are closely linked to cyclical performance of the economy.

"I would say as the yield curve steepens, it has a positive impact on equity prices on a relative basis. As it inverts, it has a negative impact on stock prices," said BofAML quantitative strategist Toby Wade. Wade's study looked at 1,300 stocks, including those in the S&P 500 and BofA's coverage universe. He looked at relative return going back 10 years, vs. the 2-year to 10-year yield curve.

The yield curve steepens when interest rates on longer duration bonds are higher than on the shorter duration and the spread between them gets wider. That is the opposite of what happened when the curve inverted in the spring and summer.

At that point, the 3-month Treasury yield was above the 10-year yield and they were moving farther apart. That "inverted" curve is viewed as a negative sign and has often preceded a recession. Now the 3-month yield is about 38 basis points lower than the 10-year yield, and heading in a positive direction. The 2-year to 10-year curve had also been inverted and is now steepening.

The BofA strategists measure stocks against a number of macro factors. Of all of them, the yield curve has become most correlated.

"Specifically, the yield curve is the most important macro factor we examined, with nearly 50% of stocks in our coverage universe and the S&P now demonstrating a statistical relationship between returns and the yield curve," he noted. That compares with just 12% in 2011.