It has been a challenging year for many U.S. retail companies, but Wal-Mart Stores Inc (NYSE: WMT) has risen to the occasion. On Tuesday, Citi analyst upgraded Walmart to "buy" and said investors should expect more of the same from the stock in 2018.

Walmart's stock has gained 43 percent year-to-date, more than double the return of the overall market. However, while investors have obsessed over identifying which retail companies are threatened by Amazon.com, Inc. (AMZN), McShane says Walmart has stealthily become a threat to Amazon.

"Our belief [is] that its aggressive omni-channel strategy will continue to drive significant sales growth, and WMT's e-commerce operations are emerging as a true challenger to Amazon, both factors that could fuel further multiple expansion," McShane says.

McShane says Walmart is well-positioned to defend its grocery business given its low prices, physical store footprint and increasingly integrated online platform. She says consensus earnings and margins estimates are currently too low, particularly for the second half of 2018.

Looking ahead to Walmart's fourth-quarter earnings expected in February, Citi estimates the company will report in-line earnings per share of $1.38. However, Citi says Walmart will surprise to the upside with same-store sales growth of 2.5 percent compared to consensus estimates of 1.9 percent growth. In the most recent quarter, Walmart reported 50 percent year-over-year growth in online sales.

Citi is also anticipating Walmart will increase its dividend payout from its current yield of 2 percent following U.S. tax reform

McShane's optimism about Walmart's 2018 extends to the rest of the U.S. retail sector as well. She says retailers are starting to recognize just how much of an asset a physical store can be and are attempting to leverage that asset by remodeling stores and focusing on differentiating themselves from Amazon.

"After years of concern about secular competition from Amazon and other online-only retailers, we think fears could start to subside in a meaningful way in 2018," McShane says.

McShane says O'Reilly Automotive Inc (ORLY) is Citi's top stock pick in the hardline retail space, but Walmart is a close second.

In addition to the "buy" rating, Citi has a $117 price target for Walmart stock.