Is it worth it to buy a stock after it experiences significant market gains? The answer is, it depends. Some companies don't have much growth fuel left in the tank after a nice run, while others still boast significant upside potential after juicy gains. It's best to stay away from the former, but the investing wisdom according to which we should "buy low" still applies to the latter.

Let's consider two companies that have performed exceptionally well recently but still have excellent long-term prospects: Summit Therapeutics (SMMT 8.18%) and SoFi Technologies (SOFI 2.46%).

Physician giving medicine to patient.

Image source: Getty Images.

1. Summit Therapeutics

Summit Therapeutics has been on a tear over the past two years thanks to progress with its leading pipeline candidate, ivonescimab. The biotech licensed out this investigational cancer medicine from China-based Akeso Biopharma. Summit Therapeutics owns the rights to the medicine in most regions, including the most lucrative ones for biotech companies: North America and Europe.

Last year, ivonescimab produced excellent results in a phase 3 study in China (where it is approved) for patients with non-small cell lung cancer (NSCLC). The study pitted ivonescimab against the market leader, Merck's Keytruda. Since Keytruda is the world's best-selling drug and NSCLC is one of its most important markets, ivonescimab's potential looks massive.

Although Summit Therapeutics' shares have already soared as a result, the company's future still looks bright. Here are two reasons why. First, Summit Therapeutics is conducting late-stage studies for ivonescimab in the U.S. and is expected to release key data readouts in the next couple of years, which could significantly affect its stock price.

Second, even though NSCLC is going to be a crucial market for ivonescimab's success, the medicine looks like a potential pipeline in a drug. It is being tested across many different types of cancers. Ivonescimab could rack up approvals and label expansions for years to come.

Summit may encounter clinical or regulatory setbacks. It's good to keep that in mind before initiating a position. But the stock could deliver monster results in the next five years if its master plan comes to fruition.

2. SoFi Technologies

Shares of SoFi -- an online bank -- have more than doubled over the trailing 12-month period. That's an impressive achievement, especially considering the somewhat challenging economic conditions we face. Many fear that President Donald Trump's trade agenda could lead to inflation or a recession. That would affect consumer behavior, resulting in slower loan demand and increased loan defaults, all of which would be detrimental to SoFi.

Despite the risk, the market has been impressed with SoFi's financial results. In the first quarter, the company's revenue increased by 20% year over year to $771.8 million. SoFi's net income dropped by 19% year over year to $71.1 million, but it was well above management's own guidance. SoFi's results were strong across the board, with the company's membership and products also moving in the right direction. That will remain the blueprint for long-term success for SoFi.

First, the number of members on its platform should continue growing. SoFi is an entirely online bank with no physical locations (which allows the company to save on overhead costs). Digital banking is the future, as evidenced by the fact that younger generations are more likely to engage in it than older ones. Legacy banking institutions have adapted, but SoFi is also popular -- it ended Q1 with a record 10.9 million members, up 34% compared to the year-ago period.

Second, SoFi could grow its revenue even without expanding its membership base, by cross-selling additional products to its existing users. The company recorded 15.9 million products in Q1. That means it had, on average, about 1.5 products per member, despite offering many more than that amount.

Third, SoFi has consistently expanded its pool of offerings, which provides other growth opportunities and makes its platform even more attractive to consumers. Although the stock could suffer in a recession, SoFi is well-positioned to perform well over the long run. So, even after its terrific performance in the past year, the stock remains a buy.