Stocks jumped on Wednesday, extending a recovery from the sharp sell-off in October with broad-based gains, after midterm elections that will split control of the United States government between both major parties.

The S&P 500 rose 2.1 percent, led by giant technology companies including Amazon, Apple and Google. The tech-heavy Nasdaq composite index rose 2.6 percent, its strongest gain this month.

Stock in consumer discretionary companies climbed 3.1 percent, in a sign of growing optimism that President Trump, stung by his party’s loss of the House of Representatives, could seek a win by striking a trade bargain with China at the Group of 20 summit meeting this month. Shares of Wynn Resorts, the casino company with significant business in China, jumped 3.9 percent.

After weeks of uncertainty heading into the election, investors seemed to focus again on the strong fundamentals for American businesses, helping fuel the gains on Wednesday.