If this were horse racing, Canadian Pacific Railway's (NYSE:CP) third quarter was like winning a trifecta pick. The company delivered on just about every measure you would want from a stock, and Wall Street seemed to like it as the stock received a hefty after-hours trading bump. 

Let's take a look at what happened at Canadian Pacific this past quarter and why Wall Street was quick to reward the result.

Railroad locomotive at dusk.

Image source: Getty Images.

By the numbers

Result Q3 2017 Q2 2017 Q3 2016
Revenue CA$1.59 billion CA$1.64 billion CA$1.55 billion
Operating income CA$690 million CA$679 million CA$657 million
Net income CA$510 million CA$480 million CA$347 million
EPS (diluted) CA$3.50 CA$3.27 CA$2.34

Data source: Canadian Pacific Railway earnings releases. EPS = Earnings per share.

Canadian Pacific's results are proof that if you make small, incremental improvements across the entire company, it can lead to large improvements to the bottom line. For the quarter, revenue was up only 3%, but most of the operating metrics for the company improved ever so slightly year over year to produce a 5% increase in operating income. 

Operating Metric % Improvement
Average terminal dwell time 6%
Average network speed (3%)
Car miles per day 2%
Gross ton-miles per locomotive horsepower 1%
Average train weight 1%
Average train length (1%)

Those results -- plus a CA$105 million gain from foreign currency fluctuation -- helped to boost net income by 46% compared to this time last year. Of course, any gains from foreign currency are a fleeting thing, so investors shouldn't give too much weight to that result. Even without it, though, it represents a 17% improvement.

One of the things that worked in Canadian Pacific's favor is the company's diversity of shipments. No single commodity or product amounts to more than 16% of total revenue, so even though the company saw 18% and 17% reductions in automotive and fertilizer shipments, respectively, it was able to make up for it with large increases for potash, petrochemicals, and bulk metals & minerals.  

What made these results look even better is that they gave management confidence to raise guidance for the full year. The company now expects double-digit adjusted EPS growth compared to last years result of CA$10.29 per share. Previously, management was expecting 2017 adjusted EPS growth to be in the high single digits.

What a Fool believes

A railroad is one of those stable investments that won't make you rich tomorrow, but when managed right, it can be a great wealth builder for your portfolio. A well-run rail company keeps its operating ratio low -- an industry term that is operating costs as a percent of revenue, the lower the better -- and throws off lots of free cash flow that can be used to pay dividends and repurchase shares. 

With an operating ratio of 56.7% last quarter, Canadian Pacific continues to be one of the best in the business -- bested only by Canadian National Railway in North America. So far in 2017, it has generated CA$575 million in free cash flow that is more than enough to cover dividends and repurchase about CA$368 million in shares. These kinds of qualities make the company look attractive, and most recent results suggest that things could get better from here.

Tyler Crowe owns shares of Canadian National Railway. The Motley Fool owns shares of and recommends Canadian National Railway. The Motley Fool has a disclosure policy.