Whoever thought railroads had hit a roadblock was in for a huge surprise in 2016 as railroad stocks gathered steam despite sluggish end markets. Take Union Pacific Corporation (UNP -0.88%), for example. The behemoth was among the top performers in the industry with nearly 33% gains, second only to CSX Corporation (CSX -1.95%), which clocked 39% gains during the year. Interestingly, Union Pacific's run-up doesn't quite match up with the double-digit declines in the company's freight revenue and net income during the first nine months of 2016.

Image source: Getty Images.

That leaves investors facing a difficult question: Can Union Pacific chug along in 2017, or is the stock already overheated? The answer, as we shall soon see, might be discomforting.

What drove Union Pacific stock up in 2016

After a tumultuous 2015, investors were largely betting on a recovery in the energy and agricultural sectors to boost railroads' prospects in 2016. Reality was harsh, though: Grain volumes were strong, but demand for consumer goods slowed, hardly any coal moved around, and tumbling oil prices caused ripple effects across several industries including chemicals and industrials. One look at the pie chart on the right explains why that must've pinched Union Pacific.

Image source: Union Pacific

Union Pacific's numbers reflected the headwinds: Freight revenue slumped 11% on the back of an 8% drop in revenue carloads during the nine months through Sept. 30, 2016. Coal was the weakest segment, followed by industrial products and intermodal. Union Pacific wasn't alone: CSX too saw its freight volumes and revenues decline 8% and 11%, respectively, during the period.

So why are investors optimistic about Union Pacific? Three factors might have played a role: a rebound in oil and commodity prices as 2016 progressed, Union Pacific's ongoing restructuring efforts, and the dividend bounty the railroad announced this past November. While I won't even try timing the bottom in commodities, the other two factors are worth a look.

One area where Union Pacific hugely disappoints

In line with weak market conditions, Union Pacific furloughed around 2,700 train, engine, and yard workers, and sent 1,600 locomotives in storage in 2016. Unfortunately, the company still failed to deliver where it matters: its operating ratio.

An operating ratio measures a railroad's operating expenses relative to its net sales, a declining ratio is a sign of management efficiency. Union Pacific's operating ratio for the first nine months of 2016 rose a percentage point, to 64%. If investors are encouraged that it's still ahead of CSX's operating ratio of 70% for the period, they might also want to know that Canadian National Railway's (CNI -0.20%) operating ratio hit a record low of 53% during its last quarter. In other words, Union Pacific is at the higher end of the industry cost curve despite its size and scale. That should be a major deterrent for investors right now.

Union Pacific's biggest challenge in 2017

Keeping the unpredictable macro factors and speculation about a potential Trump presidency benefits aside, I believe Union Pacific's turnaround depends a great deal on its core pricing power. As of now, it's deteriorating and presents an ugly picture.

Image source: Union Pacific

With volumes and prices under pressure, improving its operating ratio will be a big challenge for Union Pacific unless it pulls up its socks on the cost front. I'm not too optimistic, though, given management's lackluster goal of hitting operating ratio of 60% by 2019. You can certainly find more efficient railroads to bet your money on.

In fact, it looks like speculative bets have largely driven Union Pacific shares up. The stock is already trading higher than its five-year average P/E at 21 times trailing earnings, and isn't really a bargain at 12 times price-to-cash flow and four times price-to-book value, either. Don't get me wrong: Union Pacific is a fundamentally strong company with a solid dividend streak, having just hiked its dividend by 10% and yielding 2.3% currently. But with growth projections hovering at only around 7% for the next five years, I'd rather wait for Union Pacific's prices and volumes to get back on track before paying a premium.