Tesla Inc. shares ended at record on Friday, their third straight session of gains, and it is starting to look a lot like a rout for short sellers.

Tesla TSLA, +5.04% shorts are down $1.16 billion in mark-to-market losses this week, S3 Partners, a financial technology and analytics firm, said in a note Friday.

The stock is up more than 13% since Monday, and it rose 0.4% to end at a record $405.59 on Friday. It traded as high as $413.

See also:Tesla stock tops $400, sets fresh record

Before this week’s rally, Tesla last had set a record high close in September 2017.

For the year, the shorts, who bet on a stock falling in price, are down about $2.43 billion, S3 said.

“Tesla short sellers were in the ‘best of times’ and up +$5.16 billion in net-of-financing mark-to-market profits” as Tesla lost 46% from Jan. 1 to June 3, nearly offsetting the about $5.75 billion in losses shorts incurred from 2016 to 2018, S3 said.

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

“While we have seen a large amount of short covering in the second half of 2019, actual $ short interest or dollars at risk has increased by +$2.47 billion since June 3,” S3 said. “Short interest has ranged between $8.4 billion and $10.8 billion as Tesla’s shares shorted has decreased while its stock price has rallied over the last seven months.”

A “significant amount of shorts” have held their ground. If the rally continues, though, there will be more short covering as more short sellers hit their risk limits, S3 said.

The total Tesla shares shorted is 25.46 million, just 1.23 million shares above the three-year low of 24.23 million shares shorted hit on Jan. 30, while the $10.29 billion in short interest is at last year’s average, S3 said. The number of Tesla shares shorted have not gone below 20 million since mid 2013.

If the stock keeps “hitting historic highs we can expect short covering to accelerate as short mark-to-market losses mount,” S3 said. At this rate, the number of Tesla shares shorted would slid below 20 million shares if Tesla’s stock price hits $450 a share and another $1 billion of mark-to-market losses hits the short seller’s ledgers, S3 said.

“What was a seven month long ‘hug’ is turning into a full-blown ‘squeeze.’”

The recent gains have pushed Tesla gains for 2019 to 22%, compared with 29% and 22% for the S&P 500 index SPX, +1.59% and the Dow Jones Industrial Average. DJIA, +1.33%