What happened

October proved to be yet another bumper month for Caterpillar Inc. (CAT 1.59%) Shares of the construction-and-mining equipment giant jumped 8.9%, extending their year-to-date gains to nearly 47% and emerging as one of the biggest contributors to the Dow Jones Industrials' rally.

While Caterpillar shares were holding up firm since the beginning of the month, it was the last week of October that made investors richer. Precisely, Oct. 24, when the company trampled Wall Street estimates with its third-quarter numbers.

So what

Caterpillar's third-quarter sales surged 24% year over year, and earnings more than tripled to $1.77 per share, thanks to strong end-user demand for equipment across all of its businesses -- resource industries (mining), construction industries, and energy and transportation.

Mining trucks.

Image source: Getty Images.

But it wasn't just Caterpillar's third-quarter operational numbers that sent the stock into a tizzy. The real trigger was its outlook: For the third time this year, Caterpillar bumped up its FY 2017 revenue guidance by $1 billion at the midpoint to $44 billion, and earnings to $4.6 per share from the previous midpoint guidance of $3.5 a share.

Not surprisingly, investors lapped up the big news from Caterpillar in anticipation of bigger gains as the company rides the upturn after a prolonged slump in key end markets like mining and oil and gas.

Now what

Caterpillar is coming off an extremely weak phase that lasted several years, which is why any uptick in earnings right now will look significant. Nonetheless, the worst appears to be behind the company, going by the improvement in sales from each of its business segments in recent quarters.

My only concern is that after its recent rally, Caterpillar is trading close to 22 times forward earnings and 18 times free cash flow, which could limit the upside in the stock as uncertainty persists in the mining and energy sectors. Nonetheless, as a cyclical stock, Caterpillar is purely a long-term play, and it looks like the business cycles have finally bounced off the trough for the heavy-machinery giant.