Young retail investors rushed into Tesla stock as it surged to new highs this week.

The electric automaker passed Apple as the top holding on SoFi's investing platform in late January, and by this week was significantly ahead, according to the company. Tesla was the top stock purchased on SoFi in the past six trading days.

Traders on SoFi Invest — a stock and ETF investing platform used mostly by millennials age 25 to 40 — bought 20 times the amount of Tesla stock this week relative to history. On Wednesday, Tesla represented the largest dollar amount of securities bought and sold in the platform's history.

The retail mania came as Tesla stock surged to record highs. The stock saw its biggest one-day gain in six years Monday, closing 19.9% higher. Tuesday, the stock hit an intraday record of $968.99 a share and more than 50 million Tesla shares changed hands — a record for a single day of Tesla trading.

But Tesla's move on Wednesday showed the risk of chasing a stock which many believe is becoming a bubble like the dot-com names of two decades ago: the shares tanked by 17% in a single day.

There were also record SoFi investors buying Tesla in fractions of a share. This week saw the most users buying a Tesla "stock bit" of a security in the platform's history. SoFi began offering fractional trading in July. Charles Schwab, Square and Robinhood have since announced the same "fractional trading" feature.

Shares of Tesla have doubled this year, driven by analysts upping price targets and short-covering by those who bet against Elon Musk's automaker. Long-time Tesla investor Ron Baron forecast the company will top top $1 trillion in revenue in a decade.

The Tesla volatility has eased a bit as of Thursday with shares up 5%. The stock has rallied more than 88% year to date, and 148% in the past year.

— CNBC's Michael Sheetz contributed reporting.