Tesla Inc. stock soared past $400 to close at a record on Thursday, the culmination of a late-year rally that started in October when the Silicon Valley car maker surprised investors by showing a profit for its third quarter.

Tesla TSLA, +5.04% shares rose 2.8% to end at $404.40, trading as high as $406.85 during the session. That surpassed a closing record set on Wednesday, when the stock gained 3.7% to end at $393.15. The previous record close had been set at $385.00 in September 2017.

The run has brought Tesla’s 2019 gains to 21%, compared with advances of 28% and 22% for the S&P 500 SPX, +1.59% and the Dow Jones Industrial Average DJIA, +1.33% in the same period.

Tesla’s market valuation is north of $73 billion, ahead of General Motors Co.’s GM, -0.37% $53 billion and Ford Motor Co.’s F, -2.25% $37 billion.

Some investors see potential for margins in China to be above the company average around 25%, said Bill Selesky, an analyst with Argus Research. A positive report this week from Credit Suisse, known bears on the stock, also likely helped, he said.

Earlier this week, analysts at Oppenheimer said that the production ramp in China was likely to be “smooth.” And, after a visit to the Tesla “gigafactory” in Nevada, Dan Levy of Credit Suisse said Tesla’s batteries offer it a clear advantage over other auto makers.

The company in October reported a surprise GAAP and adjusted profit for the third quarter, kicking off the late-year gains for the shares, which include a 31% advance for October.

Related:Jim Chanos on Tesla: ‘We are still bears’

Tesla is also fresh from showing off its “Cybertruck,” and Chief Executive Elon Musk has said the pickup truck already has received about 250,000 preorders, which each including a $100 refundable deposit.

Tesla is expected to report fourth-quarter deliveries in early January and fourth-quarter results likely in February.

Analysts polled by FactSet expect the company to report an adjusted profit of $1.30 a share on sales of $6.7 billion. That would compare with an adjusted profit of $1.93 a share on sales of $7.2 billion in the year-ago period.