If the midterm elections go as Wall Street expects, stocks should rally into year-end, according to RBC. Voters go to the polls Tuesday, and the consensus view is that Republicans will take back control of one or both chambers. "The conventional wisdom that the stock market likes political gridlock is supported by the historical data in this instance," Lori Calvasina, RBC's head of U.S. equity strategy, wrote in a note to clients Monday. The average S & P 500 returns are higher in the years when a Democrat is president and the GOP controls Congress, her analysis showed. When Republicans only held one chamber, the index rallied 14%; it gained 13% when the GOP had full control of Congress. A Democratic sweep, on the other hand, resulted in a 10% return, she said. Different scenarios If Democrats keep control of Congress, it will have a short-term negative effect on stocks since a GOP win of at least one chamber is already priced into the market, Calvasina said. If Republicans win the House, S & P gains may be modest. The S & P has already rallied about 9% from its mid-October low, fueled in large part by the shift in momentum to Republicans from Democrats seen in polling data, she said. The typical midterm bounce is 7.1%. However, there is a precedent for further gains, Calvasina said. This year is most similar to 2002 — so far the S & P has had a 76% correlation with 2002, the strongest in any midterm election year in recent decades. Back then, the S & P rallied back 20% from its October lows, she said. However, the biggest positive impact on the market would be the GOP gaining full control of Congress, she said. "Republicans' chances of taking back the Senate have generally been viewed as lower than their chances of taking back the House," she said. "If Republicans take back control of both chambers, it will be viewed by equity market participants as pointing to good momentum for Republicans heading into the Presidential race in 2024." Sectors to benefit Communications services, energy and industrials will likely benefit the most from Republicans gaining control of at least one chamber of Congress largely because of what it would mean for the regulatory backdrop, according to RBC analysts. Within communication services, cable, telecom, media and internet/social media and search are poised to do well. Within energy, exploration and production should benefit the most, and refiners and midstream and master limited partnerships should also outperform. Within industrials, RBC analysts are bullish on aerospace, multi-industry and electrical equipment, railroads and defense. Additionally, biotech in the health-care space and specialty/consumer finance and regional banks within financials should outperform, according to RBC. — CNBC's Michael Bloom contributed reporting.