Stocks don't always to fit into a simple storyline.

For example, much of the financial media has talked about a "retail apocalypse", with venerable chains like Toys "R" Us declaring bankruptcy and Sears Holdings following closely in its footsteps. But the reality is that a number of big-box chains are actually thriving: Among the stocks that are flirting with 52-week highs are Kohl'sBest Buy, and Target.

But perhaps no retailer exemplifies the turnaround in this sector more than Macy's (NYSE:M), a  retail fixture since the 1800s. Macy's shares are now up 60% this year, and have more than doubled since their 52-week low last November. Along the way the company broke a streak of 12 straight quarters of comparable sales declines, and has showed signs of long-term growth for the first time in years. Let's take a look at how Macy's got to its recent high above $40, and whether or not the stock is a buy today.

A surprising comeback

When Macy's stock bottomed last November, investors were ready to give up on retail stocks, especially department store chains like Macy's. However, trends have improved significantly through the last three quarters, and the company has also made some important strategic decisions. Meanwhile, the company is benefiting from a lower tax rate and real estate sales.

The retailer reported solid comparable sales growth during the key fourth quarter: Comps on an owned basis were up 1.3%, and adjusted earnings per share increased from $2.02 to $2.82, though that included a $0.48 benefit from the sale of its Union Square Men's store building in San Francisco.

Macy's followed that up with a blowout first-quarter report. Comparable sales growth accelerated to 3.9% on an owned basis, and management said the company exceeded its own expectations in the period. Adjusted earnings per share surged from $0.12 a year ago to $0.42, a sign of the operating leverage that rising comparable sales gives the company. It also raised its adjusted EPS guidance for the year to $3.75-$3.95, up from a prior range of $3.55-$3.75.

At the same time, Macy's is tapping new growth channels like its off-price Backstage stores, following the lead of companies like TJX CompaniesRoss Stores, and Burlington Stores, which have delivered steady growth with the off-price model. In the first quarter, Macy's opened 20 Backstage locations inside existing stores, and expects to add a total of 100 Backstage stores this year, a sign that the concept is delivering favorable results. 

Additionally, Macy's also acquired the concept store Story, bringing on board Story founder Rachel Schectman, who has become Macy's brand experience officer and is expected to revamp the stores. More recently, Macy's acquired a minority stake in B8ta to help develop the company's new experiential "Market @ Macy's" concept.

Finally, the BlueMercury beauty brand the company acquired in 2015 presents another growth opportunity for Macy's, and it plans to add 55 new BlueMercury locations through 2019.

The Macy's store in Herald Square

Image Source: Macy's.

Numbers to know

In addition to its momentum, there are a couple of other reasons Macy's looks appealing today. The stock trades at a P/E of just 10.3 based on this year's expected earnings, and offers a dividend yield of 4.2%. The dividend is well-funded, as the stock has a payout ratio of about 40%.

In addition to the retail business, Macy's also owns impressive real estate portfolio, which includes downtown locations like the one in Manhattan's Herald Square. Last year the company booked $368 million in real estate gains, and it has formed a strategic alliance with Brookfield Asset Management (NYSE:BAM) to help unlock value in its real estate. Macy's recently sold off the upper floors of its Downtown Chicago building, and is exploring opportunities to sell its main Union Square building in San Francisco. 

Its real estate holdings are worth an estimated $16 billion according to investment banking firm Cowen, more than its market cap today at $12 billion. Some have argued that that's the best reason to own the stock.

Is it a buy?

Macy's is set to report second-quarter earnings, with analysts expecting flat revenue of $5.55 billion and an increase in adjusted EPS from $0.48 to $0.50.

The company is making a number of smart moves, and its real estate portfolio gives the company unique ballast. However, it's also facing significant headwinds, the biggest of which is e-commerce and Amazon. Though the company has posted consistent growth in digital sales, its cavernous stores will remain the beating heart of the business, and that could put a drag on revenue growth in the coming years as online takes share from physical retail.

The Macy's of the future will likely have fewer stores. The ones remaining will be concentrated in high-traffic urban areas, and the company will be invested more in growth businesses like Backstage and BlueMercury.

Macy's could dazzle the market again when it reports earnings, but the downside risk remains too high for me to call it a buy, especially as the stock is vulnerable to a recession or a weakening economy.  Analysts also see EPS sliding to $3.48 next year, a sign of the unique benefits the company is receiving this year, including the tax cut and the robust economy. 

The stock could continue to move higher on a strong earnings report, but don't be surprised to see investors flee on weak numbers. Though I'm impressed with management's recent moves, there are safer bets available in the retail sector.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Jeremy Bowman has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Amazon. The Motley Fool has a disclosure policy.