The stock market is rallying, and in this environment, it looks tempting to jump on the bandwagon and buy stocks that have led the gain. This isn't always a good idea, though, because some of these stocks may have climbed too far too fast. But in certain cases, these high-momentum stocks actually offer more room to run.

How do you find these jewels? By looking at companies' long-term prospects. If they're promising, these rallying stocks may advance some more in the near term and go on to extend gains over time. It's also a good idea to study the companies' track records as successful ones give you another reason to get in on these players.

Often, a recent stock split indicates a company has been doing well, too, and expects its shares to increase again in the long run. With a stock split, companies offer more shares to current holders to bring down the price of each individual share.

Let's check out two spectacular stock-split stocks that have led gains so far -- and could continue rising. They may boost your portfolio before the new year and beyond.

A notepad with "2024 resolutions" written on it is positioned on a table next to a cup of coffee and a pair of glasses.

Image source: Getty Images.

1. Amazon

Amazon (AMZN -0.66%) completed a stock split last year after years of gains pushed the stock price over $3,000. The stock didn't immediately roar higher, but this year, it's advanced about 70% and has what it takes to keep climbing -- thanks to the company's dominance in two high-growth markets: e-commerce and cloud computing. These industries both are expanding in the double-digits, and Amazon, as a longtime leader, should benefit now and into the future.

The company is especially set to thrive thanks to recent moves it made to improve its cost structure. Faced with a challenging economy and some internal issues, like excess fulfillment capacity, Amazon focused on cost cuts, efficiency, and investing in high-growth areas like technology infrastructure, and artificial intelligence (AI).

These efforts are bearing fruit, as investors have seen in recent earnings reports. In the latest quarter, Amazon reported gains in net sales, net income, free cash flow, and other key financial metrics. The company also made gains in delivery times, thanks to shifting its fulfillment model from a national one to a regional one. Delivering across shorter distances makes the process quicker -- pleasing customers -- and saves Amazon time and money.

As for cloud services, Amazon has made progress here, too. The company recently said that Amazon Web Services (AWS) customers are deploying new projects after watching their budgets earlier in the year. This is great news since AWS generally has driven profit at Amazon.

Meanwhile, Amazon shares are trading for 54x forward earnings estimates, lower than more than 80 a couple of years ago. This represents a solid buying opportunity right now.

2. Tesla

Tesla (TSLA 4.34%) also split its stock last year after the price soared above $1,000. Like many other growth stocks, including Amazon, it fell last year as investors shied away from stocks that were most sensitive to the economy. But Tesla shares have taken off this year, increasing 90%, and the gains likely aren't over. And here's why.

Even though Tesla faces economic headwinds and has had to deal with rising costs and negative currency impact, the long-term outlook remains bright. The company is the leader in the electric-vehicle (EV) market, and although it may lose some share to rivals, it has the brand strength necessary to stay in the lead. Tesla's brand is its moat, or competitive advantage, and a solid moat is a huge plus, offering some visibility on future revenue.

Tesla also is investing in key areas that should help it stand out -- and stay ahead of the competition -- over time. For example, its investments in AI have led to the creation of its Dojo supercomputer, an AI-based technology that could help the company rapidly update self-driving software and complete other crucial tasks.

Through today's difficult economy, Tesla also has managed to grow revenue, production, deliveries, and its cash position -- and remain profitable. The automaker recently said its cash position reached $26 billion, a huge plus for a company that needs to invest heavily to meet growth goals.

Tesla may not look cheap trading at more than 70x forward earnings estimates. But the EV-giant's shares are less expensive by this measure than they were a couple of years ago -- and at the same time, Tesla has grown revenue and vehicle deliveries. So this isn't an excessively high price to pay for Tesla stock today, especially considering the potential for long-term share performance.