Shares of Valero Energy (NYSE: VLO) hit a 52-week high yesterday. Let's take a look at how it got here to find out whether there are still clear skies ahead.

How it got here
Valero's been one of the refining industry's best performers over the past year. Much of that growth occurred, oddly enough, after what seemed like a weak, first-quarter-earnings report. The company's divestiture of an unprofitable Caribbean refinery seems to have sparked renewed investor interest, as the stock's been on a tear, returning 16% since the day of its earnings report:

VLO Total Return Price Chart

VLO Total Return Price data by YCharts

Although HollyFrontier (NYSE: HFC) and recent spinoff Phillips 66 (NYSE: PSX) have outperformed Valero in that time frame, the 52-week period really shows how far Valero's pulled away from the pack.

VLO Total Return Price Chart

VLO Total Return Price data by YCharts

These gains have brought Valero's stock price even with its tangible book value, as it was trading at a discount before its current run-up. Is this optimism justified? Let's dig into some key numbers to figure it out.

What you need to know
None of these refiners have exceptional net margins, but Valero's are the weakest. Its net income has been highly variable over the years as well, owing to the whipsaw action of oil prices in the past decade. I'll explain its income fluctuations in a moment, but let's take a look at the numbers first:

Company

P/E Ratio

Price to Free Cash Flow

Net Margin (TTM)

3-Year Annualized Income Growth

Valero 9.7 13.4 1.2% NM
HollyFrontier 6.2 7.5 6.5% 289.3%
Hess (NYSE: HES) 13.3 NM 3.4% 19.4%
CVR Energy (NYSE: CVI) 8.5 6.6 4.6% 64.1%
Phillips 66 5.3 7.3 2.5% 117.2%

Source: Morningstar. NM = not material due to negative results.

Five years ago, Valero's net margin was 5.5%. Margins didn't return to full single digits until 2011, and even then they were razor-thin. Contrast that with its competitors and that looks a bit inadequate.

Only Hess has a higher P/E and a worse price-to-free-cash-flow ratio (on account of extremely high capital spending) -- no wonder it's the worst performer. CVR Energy has been the target of corporate raider Carl Icahn, who might break up the company into more profitable parts. Phillips might be a recent spinoff, but it's still the largest independent refiner in the United States, and it does look quite cheap compared to its peers.

Valero's gains seem less deserved than those of its peers, unless you happen to believe that it deserves a premium valuation for bargain-bin margins. Its recent refinery sale might improve those margins, but will that be enough to change it from "slightly higher than average" to "more upside ahead?" The price of oil will also be important. A barrel now sells at the low end of its two-year range, and the global economy may pressure it lower still before a rebound:

Cushings, OK Crude Oil Futures Contract 1 (Daily) Chart

Cushings, OK Crude Oil Futures Contract 1 (Daily) data by YCharts

What's next?
Where does Valero go from here? The price of oil is going to be a big driver, but the company's also got to improve its efficiency and turn around the unprofitable refineries in its network. These gains may not last long without some signal that oil prices and oil demand are back on the upswing.

The Motley Fool's CAPS community has given Valero a five-star rating, with 96% of our CAPS players expecting the company to continue to outperform.

Interested in tracking this stock as it continues on its path? Add Valero to your Watchlist now, for all the news we Fools can find, delivered to your inbox as it happens. Valero's won't be the only stock to grow from oil price increases -- in fact, other companies might wind up with even better gains. Find out more about the three stocks for $100 oil in The Motley Fool's popular free report. Click here to get the information you need, at no cost.