Covering the modern period for the S&P 500, investing only when a Republican was in the White House, a $10,000 initial investment in 1961 would have grown to more than $102,000 by 2023. On the other hand, the same $10,000 investment would have grown to $500,000, investing only when a Democrat was in the White House. The moral of the story is that the same $10,000 initially invested in 1961 would have grown to $5.1 million by just staying invested, without regard for the political party in power.
Sources: Schwab, Liz Ann Sonders / Kevin Gordon, Nick Murray