Roku (ROKU 1.33%) is one of Cathie Wood's favorite stocks. It's the second-biggest holding across her Ark Invest funds. It's weighted heavily in the flagship Ark Innovation ETF (ARKK 0.67%) and the Ark Next Generation Internet ETF (ARKW 0.44%).

But Wood and her team have been selling Roku shares lately. Ark funds have dumped over 900,000 Roku shares since the start of November. Meanwhile, there's one stock Ark Invest has been buying to replace those shares.

The company is focused on a similar space as Roku, but its stock has been beaten down lately. Still, it plays a leading role in an industry experiencing secular growth, which means it could ultimately be worth a lot more.

It may be time for investors to follow the lead of Cathie Wood and her team and buy up shares of The Trade Desk (TTD -0.86%).

Two earnings surprises going in opposite directions

Both Roku and The Trade Desk reported their third-quarter earnings results earlier this month, and the market had very different reactions.

Roku posted an acceleration in revenue growth for the third quarter. Sales jumped 20% on the back of rising active accounts and increased user engagement. The numbers exceeded analysts' estimates for the period, but even more important was Roku's fourth-quarter outlook. Management expects to maintain its advertising growth rate through the end of the year.

Shares of Roku skyrocketed after the report with analysts raising their price targets.

Wood and her team took the opportunity to trim their funds' positions in Roku at higher prices, selling off chunks of the stock throughout November.

The Trade Desk had a decent third quarter. Its revenue and earnings came in ahead of analysts' expectations, up 25% and 27%, respectively. But things turned sour when management started talking about the fourth quarter.

In particular, executives see several negative factors impacting its revenue, including a lull in ad spending due to the autoworkers and actors' strikes and general macroeconomic uncertainty. As such, management's guidance for just an 18% top-line increase and a 10% rise in adjusted EBITDA was a big letdown for investors.

The market punished the stock the day after earnings, sending the share price down over 20% at one point.

That's exactly when Wood pounced. Ark Invest bought up 542,620 shares of the stock for the Ark Innovation ETF on Nov. 10, the day after the earnings release.

The good news for investors is that as of this writing, The Trade Desk stock trades for close to the same price as it did just after earnings.

Should you sell Roku for The Trade Desk?

Both Roku and The Trade Desk are two of the best ways for investors to take advantage of the secular growth of streaming media and connected TVs.

The Trade Desk focuses exclusively on the ad technology behind buying digital advertising. Over the last few years, it's come to specialize in filling demand for spots in connected TV apps. That results in a great high-margin business that's taking market share from the overall digital advertising market as connected TV outperforms.

Roku, on the other hand, has a much broader scope. It's divided into two main segments: its device sales and its platform business. Devices include streaming sticks, players, speakers, and other smart devices, as well as its new line of Roku TVs. The platform business encompasses its ad sales and revenue share from streaming subscriptions. It sells ads through its own demand-side platform, similar to The Trade Desk.

Considering Roku's robust user growth and engagement, it's building a much stronger competitive advantage in the space than The Trade Desk. It benefits from a three-sided network that brings together users, ad supply from streaming media companies and its own platform, and advertisers through its demand-side platform. Each quarter that Roku adds new users, new streaming services, and new advertisers, it grows engagement and strengthens its competitive advantage, making its product stickier.

What's more, the stock's valuation is much more attractive than the Trade Desk's. Trading at 3.9x sales, Roku's stock is well below the price of The Trade Desk, which investors will pay 18.5x sales for. Even when you look at historic valuations, Roku is offering a much bigger bargain than The Trade Desk. Roku's five-year median P/S ratio is 10.7x versus 21.9x for The Trade Desk.

ROKU PS Ratio Chart

Data by YCharts.

To be fair, Roku should trade at a discounted P/S ratio considering the drag of its device sales on its overall profits, but the device segment accounts for less than 15% of the top line. What's more, the recent strong performance in device sales, user growth, and engagement foreshadow robust growth in the platform segment going forward.

Considering Roku still holds its position as Ark Invest's second-biggest holding, investors shouldn't rush to replace their Roku shares with The Trade Desk. The firm is simply trimming its overall position in the stock after the run-up. But considering Ark Invest's analysts still see tremendous upside in Roku over the long run, it's still worth holding onto the shares.