For long-term investors, the preferred holding period for a company is forever. However, that's not always realistic, and there comes a time when investors must sell a stock (or at least some portion of the holding).

There are multiple reasons to sell a stock, such as a thesis change or business problem, but neither of those are the reasons I decided to sell some shares of The Trade Desk (TTD 6.18%) recently. Read on to find out why I sold some shares but still believe in The Trade Desk as a company.

The Trade Desk's performance has caused its valuation to skyrocket

The Trade Desk operates in the advertising market and is a platform advertisers use to bid on ad spaces. It operates in multiple locations: connected TV, podcasts, smartphones, the internet, and just about every other place you'd see a digital ad.

Despite the overall advertising market's weaknesses over this past year, The Trade Desk has held up quite well and managed to grow at a respectable pace, which shows how vital advertisers see this software as being.

The Trade Desk has been a stellar performer over the past few years. It's up nearly 90% in 2023 and nearly 800% over the past five years. In my portfolio, The Trade Desk has been the best performer, but this also led to over-concentration in the stock.

As the stock made up more than 15% of my portfolio, it reached a point where I was uncomfortable with how much of my portfolio depended on The Trade Desk's results. To make me more comfortable, I reduced my position size from 15% to 5% and deployed the cash elsewhere.

While I'm usually OK with a single stock making up 15% of my holdings, The Trade Desk's valuation has me ultra-concerned. It has reached a point in its valuation where I'm not sure the business can keep up with expectations.

TTD Chart

TTD data by YCharts

At 26 times sales, the expectations are sky-high for the stock. Let's do a quick valuation analysis to see what expectations are built into the stock and demonstrate how well The Trade Desk must do to meet them.

The stock is priced for perfection

The Trade Desk has grown its revenue solidly at about 25% over the past year, so we'll use that as its growth rate. Additionally, at peak profitability, The Trade Desk achieved about a 30% profit margin in 2021. Using those two inputs, we can calculate that The Trade Desk would have $5 billion in revenue and $1.5 billion in profits in five years if it grows at a 25% compounded annual growth rate with a 30% profit margin.

While those are impressive numbers and would illustrate a very successful five-year run for The Trade Desk, that would only bring its valuation down to 8 times sales and 27 times earnings.

So if The Trade Desk has a near-perfect five-year run, it will end up at a reasonable valuation level only if the stock price stays where it is right now. That's concerning to me, so I've reduced my position.

However, I haven't sold all of it yet for two reasons.

One, I still believe in The Trade Desk's product and market. Targeted advertising is massive and will only become more prevalent.

Second, I want to be able to track The Trade Desk's stock. Should its valuation level fall to a more reasonable mid-teens times sales, I'll gladly repurchase some shares. Until that time, The Trade Desk is too rich for my blood.

Selling shares of a stock isn't always ideal, but when there are more attractive opportunities elsewhere, it's a smart thing to do. I still like The Trade Desk as a company, but it's not worth it as an investment right now.