Last week was not a lot of fun for Whole Foods Market (NASDAQ:WFM) shareholders.

On Wednesday, Whole Foods reported fiscal second-quarter earnings that missed analyst estimates on both sales and earnings. Whole Foods then added insult to injury by cutting its earnings guidance for the rest of the year -- its third such guidance cut in the past six months. 

Investors responded to the news by dumping the stock, sending Whole Foods shares down 19% in a day. Just like that, Whole Foods lost $3.3 billion worth of market cap -- and investors found each of their shares worth $9 less than before the earnings news broke.

Meet the analyst who warned you about Whole Foods
That is to say, most investors lost $9 a share on Whole Foods last week. A few lucky investors managed to sidestep the panicked rush for the exits, avoid the huge losses, and get out before the bad news broke. How did they do it?

They got an early warning to dump Whole Foods stock, that's how. And it was an analyst at independent stock research firm Wolfe Research who warned them.

Source: TipRanks.

According to stock analyst tracking and ratings site TipRanks, the top-ranked (bearish) analyst currently following Whole Foods is a gent by the name of Scott Mushkin, who works for Wolfe. On May 5, a day before Whole Foods' earnings came out, Mushkin told Bloomberg Businessweek that although "Whole Foods is probably one of the finest retailers out there ... a lot of products that were once available at Whole Foods and hard to get at other places are now more widely available."

According to Mushkin, rivals such as Kroger (NYSE:KR) and H-E-B have been stealing market share from Whole Foods by catering to middle-class shoppers who want to buy the occasional organic or high-end grocery product -- but don't want to have to visit a separate store to get it. This, says Mushkin, has led to a slow decline in store performance (same-store sales) at Whole Foods that's been going on since about Q4 2012.

The crystal ball worked
Bearing this in mind, and fearing what this trend might mean for Whole Foods' fiscal Q2 earnings results, Mushkin blew the whistle on Whole Foods Tuesday, a full day before Whole Foods' earnings came out, and told investors to sell the stock before earnings. Turns out, he was right about that -- and not for the first time.

According to TipRanks, which keeps tabs on well over 3,000 individual analysts working for some of Wall Street's best-known firms, Mushkin is near the top of the heap. Of the 22 stock recommendations that the analyst has made over the past four years,  64% have generated positive profits for investors, and Mushkin's average recommendation returned a whopping 15.3% profit over the succeeding year -- beating the S&P 500 by 4.5 percentage points. This kind of performance is good enough to win Mushkin a rank of No. 228  out of the 3,075 analysts  that TipRanks tracks. (Note: These numbers will vary slightly from day to day, as stock prices fluctuate.)

Any more bright ideas, stock genius?
That's all well and good for investors who listened to Mushkin last week, of course. But how does it help you today? Well, as it turns out, Mushkin also has low expectations for another pretty famous grocer -- Wal-Mart Stores (NYSE:WMT) -- a stock that, according to TipRanks, he is rating a sell. Wal-Mart is set to report earnings today.

Looking only just a bit farther out, Mushkin also has an idea for a stock you might buy in order to make back some of your losses from not selling Whole Foods last week. And it's the very same grocery store chain that Mushkin blames for stealing Whole Foods' thunder last week: Kroger. According to Mushkin, Kroger shares are very much a buy at today's share price of less than 16 times earnings (Whole Foods, by the way, still costs 26 times earnings even after its sell-off, while Wal-Mart sells for a bit more than 16 times earnings).

Will he be proven right again? We won't have to wait too long to find out; Kroger reports its earnings next month. 

Source: TipRanks.

Top dividend stocks for the next decade
Unimpressed by Whole Foods' 1.2% dividend yield? Maybe you should be -- Wal-Mart, after all, pays a dividend twice as big, and even Kroger pays more than Whole Foods. The smartest investors know that dividend stocks simply crush their non-dividend-paying counterparts over the long term. That's beyond dispute. They also know that a well-constructed dividend portfolio creates wealth steadily, while still allowing you to sleep like a baby. Knowing how valuable such a portfolio might be, our top analysts put together a report on a group of high-yielding stocks that should be in any income investor's portfolio. To see our free report on these stocks, just click here now.

John Mackey, co-CEO of Whole Foods Market, is a member of The Motley Fool's board of directors. Rich Smith has no position in any stocks mentioned. The Motley Fool recommends and owns shares of Whole Foods Market. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.