Warren Buffett famously told investors to be "greedy when others are fearful." Today, there's plenty of fear regarding China's stock market and its economic health, which caused investors to dump shares of some high-quality companies. The Chinese stock market might go lower from current levels, but after the smoke clears, I would consider buying two stocks: Baidu (BIDU 0.98%) and Vipshop Holdings (VIPS 0.13%).

Shanghai. Source: Pixabay

Baidu: "The Google of China"
Baidu evolved from a simple search engine into an ecosystem of portals, cloud apps, and mobile services. But unlike its overseas counterpart Google, which let the e-commerce market slip through its fingers, Baidu is building an "O2O" or online-to-offline platform to let users order products and services directly from its mobile app. By corralling businesses within its O2O ecosystem, Baidu hopes to discourage users from using third-party apps, which reduce user dependence on its services.

However, this expansion required major investments and acquisitions, which dented its margins. Last quarter, total operating expenses surged 56% annually, which caused a 2.5% decline in operating profit. "O2O and Other" investments reduced operating margins by over 25 percentage points, while investments in iQiyi, its video platform, lopped off another 5.1 percentage points. A weaker-than-expected sales forecast for the third quarter, and CFO Jennifer Li's statement that O2O penetration remained in the "low single digits" spooked investors.

The stock market chaos in China exacerbated that pain, and Baidu shares are down about 35% year-to-date. The stock now trades at just 25 times trailing earnings -- its cheapest valuation since the summer of 2013. Back then, investors were similarly concerned that bold investments couldn't help Baidu successfully transition to mobile devices. Yet those investments eventually paid off -- mobile revenue accounted for half of Baidu's top line last quarter, up from 30% a year earlier. If Baidu's bet on O2O services also pays off, a temporary contraction in margins could be well worth it.

Vipshop: An overlooked underdog
Vipshop Holdings is a frequently overlooked in the booming Chinese e-commerce market. The online discount marketplace relies heavily on flash sales to keep customers coming back to its site. Last quarter, the company's revenues and net income respectively rose 78% and 147% -- making it one of the fastest-growing B2C, or business-to-consumer, sites in China. It was also notably the first Chinese B2C company to achieve profitability in late 2013.

Yet Vipshop remains a tiny player in the massive B2C market. Last year, it controlled only 2.9% of the overall market, compared with 61.4% for Tmall and 18.6% for JD.com. This market can be unforgiving for smaller competitors, which often have to lower prices and spend heavily on promotions just to stay relevant.

Source: Author screenshot

Despite those challenges, Vipshop has a first-mover's advantage in the flash-sales market, which forced larger competitors such as JD.com to adopt similar strategies. Vipshop also found a comfortable niche of selling leftover and off-season products from larger retailers. For example, Tmall and JD.com might contact an apparel retailer's e-commerce or marketing departments to sell its products online, but Vipshop goes straight to the clearance department to hunt for bargains. The company has also been scaling back its lower-margin "group buy" service since the third quarter of 2014. As a result, Vipshop's operating margins rose from 2.9% to 4.9% between the second quarters of 2014 and 2015.

Vipshop currently trades at around 47 times earnings despite trading down nearly 20% so far this year. It's not cheap, but it represents a steep discount from its price-to-earnings of over 100 tunes at the end of 2014. Looking ahead, the stock looks more reasonably priced at 19 times forward earnings.

The key takeaways
Investing in Chinese stocks isn't for the faint of heart. However, I believe many investors are overreacting to the weight of Baidu's O2O investments, which could pay off over the next few years. They're also overlooking Vipshop's surprising resilience in China's cutthroat B2C market and its impressive ability to expand margins and pump out triple-digit bottom line growth in the shadow of massive rivals with deeper pockets. Therefore, I believe that if the Chinese market continues to decline, investors should consider picking up these two quality stocks at bargain prices.