What happened

Shares of composite decking company Trex (TREX -1.08%) got hammered on Tuesday after the company reported financial results for the second quarter of 2022. Q2 results were better than expected, but the company expects an alarming slowdown in the second half of the year. And that's why Trex stock was down 15% as of 1:15 p.m. ET.

So what

In Q2, Trex grew revenue 24% year over year to $386 million. According to The Fly, this is about $6 million more than Wall Street expected. But perhaps more impressively, its gross profit margin increased to 40.7% compared to 38% in the same quarter last year, even though inflation threatened to do the opposite.

Trex's management was able to protect margins with timely price increases and operational efficiencies. As a result, Q2 net income increased 45% year over year to $89 million. And with the business performing well, management rewarded shareholders by repurchasing 2.8 million shares during the quarter.

Now what

Q2 was good for Trex. But management said demand dropped off of a cliff starting in June. And because of this, retail channels have enough inventory to meet demand, meaning its factories won't need to churn out as much composite decking product.

For the rest of the year, Trex only expects to generate revenue of $365 million to $385 million. For perspective, it had $640 million in net sales in the back half of 2021. Granted, those were record sales for Trex. But it's a steep and sudden drop-off nonetheless. And it's why the stock was down today.

Now down more than 60% from its previous high, Trex is experiencing its largest pullback in more than a decade. I won't deny that the decline in sales is troubling given the company's recent and ongoing manufacturing expansion. That said, this management has proved adept over the years of making lemonade out of lemons as evidenced by its gross margin expansion in Q2.

Therefore, I'd be hesitant to discount Trex's ability to generate market-beating returns over the next five years from where shares trade right now.