So far in 2017, the S&P 500 has gained nearly 8% and the stock market as a whole is hovering near all-time highs. However, not all stocks have done quite so well. Specifically, the real estate and retail sectors have significantly underperformed the market this year. Here's a retailer and two real estate investment trusts with retail-based business models, all of which have lost more than 25% of their value this year -- and now look like bargains.

^SPX Chart

^SPX data by YCharts.

1. Tanger Factory Outlets

Real estate investment trust (REIT) Tanger Factory Outlets (NYSE:SKT) owns 44 outlet shopping centers in 22 U.S. states and Canada, and has gotten crushed so far in 2017.

Couple walking down the street with shopping bags.

Image source: Getty Images.

However, Tanger Outlets is a different kind of retail. Specifically, outlet malls offer customers bargains that are difficult to find online, making them less vulnerable to e-commerce than other types of retail. Also, since the businesses occupying Tanger's space are discount-oriented, they work well in any economic environment, making the company recession-resistant. As CEO Steven Tanger says, "In good times people love a bargain, and in tough times, people need a bargain."

The proof is in the numbers. Tanger's properties are 98% occupied, and have remained above 95% regardless of what the economy was doing. The company has grown its profits consistently, and as a result, has been able to increase its dividend nearly every year since its IPO in 1993.

Finally, consider the growth potential. Outlet retail is still in its early stages. There are less than 70 million square feet of outlet space in the U.S. (several retail REITs own more space than this all by themselves – see Kimco below), and many potentially valuable U.S. markets are currently not being served at all by the outlet industry.

2. Macy's

Shares of department store retailer Macy's (NYSE:M) have gotten pummeled lately. Many retailers are struggling right now, and Macy's profits haven't exactly been immune.

However, now that it trades for just over seven times this year's expected earnings, it may be worth a look. My Foolish colleague Adam Levine-Weinberg recently wrote an excellent breakdown of Macy's turnaround plan, but in a nutshell, the company is closing underperforming stores, investing in brand exclusivity, and taking steps to create a more pleasant shopping experience in its stores.

Macy's could certainly benefit from some of the same factors that have made Best Buy such a successful turnaround story. For example, Best Buy has done a fantastic job of creating a more engaging and enjoyable shopping experience, with features like its Apple and Samsung stores-within-a-store. As I mentioned, Macy's is also taking steps to improve its shopping experience, which could produce a similar "destination" effect.

And as the strongest brick-and-mortar retailer in its specialization, Best Buy was able to survive and pick up much of the market share of weaker competitors (specifically Circuit City, Radio Shack, and h.h. gregg) that didn't make it through the tougher times. As one of the strongest department store retailers, I can see a similar outcome for Macy's.

3. Kimco Realty

Shopping center REIT Kimco Realty (NYSE:KIM), like the two other stocks mentioned here, hasn't performed too well in 2017. And it certainly makes sense, as many retailers that primarily operate in shopping centers -- such as Kmart, h.h. gregg, and Payless Shoe Source -- have all announced massive store closures in 2017.

However, the impact on Kimco has been minimal -- in fact, the loss due to these closures represents just 0.3% of Kimco's rental income.

Kimco's strategy is to operate in a little over 20 core markets, and to maintain a high level of tenant diversity. Kimco has 517 properties containing 84 million square feet of space, and 80% of the rent they generate is in these core markets. No more than 3.5% of the company's revenue comes from any single tenant, and the top tenants are made up of recession- and e-commerce-resistant businesses.

For example, discount retailers such as TJX, Ross Stores, Wal-Mart, and Dollar Tree, all of which are among Kimco's top 15 tenants, tend to do just fine during tough times, as customers seek bargains. Retailers such as Albertsons and PetSmart sell things people need, not just things people want. These are just a few examples of Kimco's roughly 4,000 individual tenants, but the point is that the company isn't too vulnerable to traditional, discretionary retail businesses closing stores.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.