What sell-off? These stocks were UP in August

What the heck is going on with stocks?
What the heck is going on with stocks?

It's been a gruesome month for stocks. But some well-known companies did surprisingly well while the broader market tanked.

Sixty stocks in the S&P 500 actually sported gains for the month of August.

There's always a bull market somewhere.

How did these stocks survive the market carnage?

Merger mania! The top three gainers in the S&P 500 were firms that received takeover offers in August -- oil services firm Cameron (CAM), utility AGL Resources (GAS) and aerospace equipment company Precision Castparts (PCP).

The lesson here? Some companies appear to be bargain hunting -- especially in the downtrodden energy sectors.

Related: Awful August: Worst month for Dow in 5 years

Schlumberger (SLB) announced it was buying Cameron the day after last Monday's market meltdown. Southern Co. (SO) actually unveiled plans to buy AGL on Monday. Both Cameron and AGL were down more than 10% this year before the mergers were announced.

And Precision Castparts? It's getting acquired by Berkshire Hathaway (BRKB), the conglomerate run by legendary value investor Warren Buffett.

All about earnings. M&A wasn't the only thing lifting stocks in August. Good, old-fashioned earnings reports helped several companies as well.

Best Buy (BBY) surged 14% as profits topped forecasts. Graphics chipmaker Nvidia (NVDA) was up 13% following a solid outlook that showed its fortunes are tied more to the lucrative gaming market and less to PCs.

And discount jeweler Signet (SIG), which owns Kay, Jared and Zales, soared nearly 15% thanks to shiny sales and earnings. Signet generates most of its revenue from the United States. So it hasn't been hurt as much by a stronger dollar and turmoil in emerging markets.

By way of comparison, luxury jeweler Tiffany (TIF), which has more exposure to China, tumbled 14% this month.

Eat, drink and be merry! Investors often flock to boring food companies during times of market turmoil. People still have to eat and drink.

These companies also tend to offer steady, if not spectacular, earnings growth rates as well as solid dividends.

Related: Can global gloom sink the U.S. economy?

To that end, Smucker (SJM)and SPAM-owner Hormel (HRL) were both up in August. So was Constellation Brands (STZ), which sells Corona in the U.S. and also owns the Robert Mondavi brand of wine as well as SVEDKA Vodka and Black Velvet Canadian Whisky. (Bottoms up while the market is hitting bottom?)

Food distributor Sysco (SYY) was also a winner in August -- although a big reason for its nearly 10% pop was the news that activist investor Nelson Peltz had taken a stake.

Bigger is better ... especially in tech. Sure, some notable tech leaders got hit in August with the rest of the market.

Apple (AAPL), Amazon (AMZN), Facebook (FB) and Microsoft (MSFT) were all down between 5% and 7%.

Still, it's worth noting that investors continued to buy some other blue chips in the tech sector. Shares of Google (GOOGL) were flat. Priceline (PCLN) and Netflix (NFLX) finished August slightly in positive territory.

It was a bumpy ride for these stocks, of course. But ending this month with even the tiniest of gains is an accomplishment. It appears to be a sign that investors aren't bailing on top tech stocks just yet -- despite concerns about high valuations and woes in China.

Personal Finance

CNNMoney Sponsors