It has been quite the roller-coaster ride for Palantir (PLTR) shareholders in the past few years. After going public in 2021, the stock entered an 80% drawdown in the 2022 bear market. Since then, it has clawed its way back with a vengeance. Shares have risen close to 500% in the past three years, making Palantir one of the best-performing stocks in the market.

Why? Two words: artificial intelligence (AI). Palantir is a software and services provider of AI tools to the government, military, and big business. Everyone loves AI stocks right now. It is seeing increasing adoption and contract wins that are driving the stock higher. But are investors who buy in 2025 too late to the party? Let's dive into Palantir stock and see if it is a buy for your portfolio this calendar year.

AI for national security (and businesses)

Palantir's software uses AI and other analytical tools to help large organizations garner insights from their data. Its custom solutions are catered to organizational needs. For example, it has contracts with the U.S. military, CIA, and other government agencies. Last quarter alone U.S. government revenue was $320 million and growing 40% year over year.

It looks like this growth is set to continue, as the company is signing huge contracts with the U.S. government. One example is a $618 million deal with the U.S. Army for a period of up to four years just recently signed. The U.S. government -- likely the largest organization in the world -- has a sprawling set of data sources that can be a pain to deal with. Just think of how hard it is to organize the data in your personal life and multiply that by a million. This is what the U.S. government is dealing with and why it is willing to pay Palantir a pretty penny to organize and analyze it.

To expand its addressable market, Palantir has shifted its focus to selling its AI tools to large enterprises. Using the government's performance with Palantir as a selling point, Palantir has made rapid inroads in selling its services to companies. U.S. commercial revenue was Palantir's fastest-growing segment last quarter, growing a rapid 54% year over year to $179 million.

Large growth prospects and room for profit margin expansion

With less than $200 million in quarterly revenue from its U.S. commercial segment, I believe Palantir has a long runway to sell its software to businesses. Last quarter alone it closed 104 deals worth over $1 million and grew its customer count 39% year over year. Software and analytical tools are sticky and usually see growing spend from customers over time. As Palantir gains more customers, its revenue should grow even faster and help consolidated revenue march higher over the next five years.

On the profitability front, Palantir has a lot of room for improvement. Over the last 12 months, its operating margin was only 13%. To be fair, this is a big improvement from years past and is low because of Palantir's reinvestment for growth, but it is still lower than most software businesses. With sky-high gross margins above 80%, I expect Palantir's operating margin to expand past 20% and eventually 30% in the next five years. This will help its bottom-line profits soar once this business starts maturing.

PLTR Revenue (TTM) Chart

PLTR Revenue (TTM) data by YCharts

Is it too late to buy Palantir stock?

Palantir stock is up 500% in the past three years and now sports a market cap of $180 billion, making it one of the 100 largest companies in the world. It's shocking when you think hard on it. This little software company with $2.6 billion in revenue is valued as one of the biggest companies on this earth, at least by market capitalization.

This is why I agree that it is too late to buy Palantir stock in 2025. If the company grows its revenue by 40% for the next five years, its revenue will hit $14 billion. Assuming its bottom-line profit margin can expand to 30%, that is $4.2 billion in annual earnings five years from now. This is a very optimistic scenario, and one I think is unlikely to even occur, although it doesn't mean Palantir won't grow earnings over the next five years.

Earnings of $4.2 billion versus a market cap of $180 billion is a price-to-earnings ratio (P/E) of 43. What this means is even if Palantir puts up 40% growth for five straight years and expands its profit margin to 30%, it will still trade at a nosebleed earnings ratio. Expectations are much too high for Palantir stock. It is highly unlikely investors will be happy buying today and holding for the next five years. Price matters when investing. Stay away from the hyped-up Palantir stock, at least for now.