When the stock market sends a company's share price down through no fault of the company, it can be a great time to buy. And the recent market turmoil has been tough on many businesses, regardless of whether they're outperforming or underperforming in their industries. 

Three companies that the market has walloped are Apache Corporation (APA -0.83%)Magellan Midstream Partners (MMP), and General Motors (GM 1.12%). Here's why these stocks look like bargains, and why today might be a good time to scoop up some shares. 

A man's hand holds a hammer above a broken piggy bank

Sometimes, the stock market hits a stock hard. That can be the best time to buy. Image source: Getty Images.

An ignored opportunity

Independent oil and gas exploration and production company Apache Corporation hasn't been able to hit its stride since announcing a monster new oil and gas find in West Texas called "Alpine High." The company shifted a lot of capital to developing the Alpine High field, and initial results have been encouraging. In spite of that, the stock market has bid the company's shares lower and lower.

Some of this sell-off may be justified by the delays Apache encountered in getting Alpine High up and running. In mid-2017, Hurricane Harvey delayed the delivery of some much-needed equipment into Q1 of this year. That, coupled with some unexpected third-party pipeline issues in the North Sea, caused lower-than-expected production in the latter half of 2017. The market, nervous that Apache was missing the opportunity to cash in on the recent spike in oil prices, sold off the stock. Apache's shares are now trading at their lowest levels since 2003.

That seems like a massive overcorrection because Apache seems to be in better shape now than it was even two years ago. It has paid down debt, achieved record Permian Basin production in 2017, and is projecting a three-year compounded annual production growth rate of more than 150% at Alpine High and 11% to 13% overall. It sold off its underperforming Canadian assets -- which is the main reason why its production volumes are down -- and recently made a big discovery in the North Sea.

I fully expect Apache's shares to rebound once the market realizes its potential, and the company's best-in-class 2.6% dividend yield should help tide investors over while they wait.

Low risk, moderate growth, high yield

Apache has been manhandled by the market over the past several years, like many energy companies. Master limited partnership (MLP) Magellan Midstream Partners, too, had a rocky 2017, with the stock currently down about 13% since January 1 of that year.

Given Magellan's strong fundamentals and its current 5.5% yield -- more than twice Apache's -- the current price looks pretty great. That said, owning an MLP isn't for everyone thanks to some complex tax rules; be sure to do your research before you buy.

Magellan's high yield looks very safe, thanks to strong distribution coverage of a healthy 1.2 times in 2017. And that yield may creep even higher over time, since the partnership's distribution -- the MLP version of a dividend -- is expected to grow by 8% in 2018, replicating its 2017 distribution increase. That would be right in line with Magellan's long investor-friendly history of increasing its distribution every quarter since going public in 2001.

The company is also known for its conservative management style and has a balance sheet that's among the best in the industry, which should help investors feel safe buying into the company. Add it all up and you get a solid choice for continued outperformance at what's currently a very reasonable price. But that price has been on the rise for the past month, so it may not be a bargain for much longer.

An American icon

If oil and gas stocks aren't your cup of tea, how about investing in an industry that uses a lot of that petroleum: the auto industry? Signs that demand may be cooling off along with concerns about steel tariffs have caused the market to give shares of General Motors and its rival Ford (F 2.50%) a double-digit haircut so far in 2018. 

Although Ford has the lower forward price-to-earnings (P/E) ratio at 5.7 to GM's 7.0 and the higher dividend yield at 5.4% to GM's 4.2%, GM may actually be the better bargain right now, thanks to some savvy moves the company has made to shore up its operations and lineup.

GM recently unveiled a new Cadillac XT4 SUV, a necessary offering for its sedan-focused luxury brand in the SUV-hungry U.S. market. This followed on the heels of new Chevrolet crossover SUV models that are selling well. GM also has posted big sales gains so far this year in major market China, where its homegrown Baojun brand is expanding like crazy. True, analysts are anticipating modest declines in global 2018 auto sales, but GM is nevertheless predicting earnings growth will return in 2019, when it will introduce a new line of full-size pickups.

While Ford isn't a bad choice to buy, General Motors seems to be eating its rival's lunch in just about every way. In any case, GM's solid prospects make it look like a great bargain right now.

Investor takeaway

Sometimes, the market does you a favor when it unfairly punishes a stock. And shares of Apache, Magellan, and GM seem to have been hit hard for things outside of their control.

Nevertheless, all three companies have good growth prospects and certainly are cheaper now than they were at the beginning of the year. Investors can feel confident picking up any of these bargains today.