The two major political parties are nearly at parity in the U.S. Congress. In the House of Representatives, Republicans narrowly outnumber Democrats 218 to 213 with four vacant seats resulting from recent resignations. In the Senate, Republicans have 49 seats compared to Democrats' 48 seats. However, three independents caucus with Democrats, giving the party a slim majority.

There's one area, though, where the two major parties aren't close at all. Democrats crushed Republicans in average stock market returns in 2023.

Lopsided returns

Last year was a good one for most investors. A new bull market that officially began in October 2022 picked up steam. The S&P 500 jumped over 24%.

Democratic members of Congress handily beat that level. Their average return was nearly 31.2%. Rep. Brian Higgins (D-N.Y.), who resigned from his seat in February 2024, was the biggest winner among congressional stock traders in 2023 with a jaw-dropping gain of 238.9%.

However, the GOP representatives and senators didn't fare nearly as well. The average 2023 return for Republican members of Congress was a hair under 18%. In a great year for stocks, the GOP delegation on Capitol Hill significantly underperformed the S&P 500.

To be sure, some Republicans in Congress were big winners. For example, Rep. Mark Green of Tennessee saw his stocks soar over 122%. The portfolios of Rep. Garret Graves of Louisiana and Rep. David Rouzer of North Carolina more than doubled in 2023. They were the outliers, though.

Democrats' not-so-subtle secret to success

Why did Democrats' gains trounce those of Republicans last year? Looking at the types of stocks the two parties invested in reveals the Democrats' not-so-subtle secret to success.

Republicans invested much more heavily in financial services stocks, oil stocks, and commodities than Democrats did. The banking crisis hurt bank stocks in 2023. Lower oil prices prevented most oil stocks from beating the market.

Meanwhile, Democrats as a group put more money in tech stocks. The impressive stock market gains of 2023 were due in large part to the terrific performances of the tech-heavy "Magnificent Seven" stocks.

All of the gains achieved by the top-performing Democrat member of Congress, Rep. Higgins, were due to his investment in Nvidia (NVDA 3.42%). The chipmaker was a popular pick for other Democratic members of Congress as well.

Nvidia benefited tremendously from the excitement over generative AI. The company couldn't keep up with the demand for its chips. Despite increased competition, Nvidia's graphics process units (GPUs) remain the gold standard for powering generative AI applications.

Amazon and Tesla were also among Democrats' favorite stocks. Both also enjoyed a tailwind from the AI boom. Amazon's shares soared 81% last year, while Tesla stock more than doubled.

Should you invest like congressional Democrats now?

Just as the political fortunes of Democrats and Republicans can shift over time, so can their investing gains. There's no guarantee that the kinds of stocks favored by Democrats last year will outperform those bought more heavily by Republicans in the future.

Valuation could be a key factor in the pendulum swinging. For example, Nvidia (a top stock with Democratic members of Congress in 2023) now trades at over 36 times forward earnings. Meanwhile, the forward earnings multiple for ConocoPhillips (an oil stock popular with Republicans) is only 13.8. It's possible that investing sentiment will move away from stocks priced at premium valuations to those with more attractive valuations.

Likewise, geopolitical events could shake things up. An escalation of the turmoil in the Middle East would likely cause oil prices to jump with oil stocks moving in lockstep.

Still, I think tech stocks -- including Nvidia -- should deliver exceptional returns over the long run thanks largely to the increasing adoption of AI. Regardless of which political party you like the most, investing in technology could pay off handsomely over the next decade and beyond.