With the stock market hovering around all-time highs, shares of unprofitable companies soaring, and bubbles in GameStop, electric vehicle stocks, cryptocurrencies, and likely other areas being inflated by rampant speculation, it can be all too easy to forget that a stock's true value is based on the fundamentals. Earnings, cash flow, and the balance sheet matter, even if they don't seem to matter all that much today.

Buying whatever stocks are popular and rising while ignoring the fundamentals is a strategy that works until it doesn't. "The market is like a large movie theatre with a small door," says Nassim Nicholas Taleb in Skin in the Game. "And the best way to detect a sucker ... is to see if his focus is on the size of the door or on that of the theater."

Many investors are piling into the hottest stocks at valuations that require some serious mental gymnastics to justify. That strategy worked last year following the pandemic-driven crash in March, and it's continued to work this year. But it won't work forever. When the euphoria fades, you'll want to own shares of companies that have the earnings and balance sheets to back up their valuations.

A roll of cash bills on top of more $100 bills.

Image source: Getty Images.

The balance sheet is particularly important given the vast uncertainty about what the U.S. and global economies will look like as the world recovers from the pandemic. While a strong balance sheet won't protect a stock from being dragged down in a market crash, it does provide the underlying company with a buffer against losses, as well as the ability to make opportunistic deals and investments.

Two mid-cap stocks that have loads of cash on their balance sheets are Kulicke & Soffa Industries (NASDAQ:KLIC) and Skechers (NYSE:SKX). Here's why you should considering investing in these underappreciated stocks.

Kulicke & Soffa

Kulicke & Soffa provides equipment used in the manufacture of semiconductors, focusing on packaging equipment that connects semiconductors to their protective casings. The semiconductor equipment business is highly cyclical, dependent on capital spending from chip manufacturers.

Right now is a great time for semiconductor equipment companies. A surge in demand for all manner of devices during the pandemic has led to a shortage of chip manufacturing capacity. Automakers have warned about chip shortages forcing production cuts, and products ranging from game consoles to CPUs and graphics cards are tough to find.

Kulicke & Soffa's revenue and profit are already soaring, and the company expects the good times to last at least another quarter. The company reported an 85% surge in revenue and a more than tripling of earnings per share in the fiscal first quarter, and it sees even higher sales in the second quarter.

More importantly, Kulicke & Soffa's balance sheet is rock solid. The company had total cash and investments of $584 million at the beginning of January, and no debt. That compares to a market capitalization of about $3 billion.

While demand for Kulicke & Soffa's equipment will ebb and flow, the company's mountain of cash will allow it to weather just about any storm.

Skechers

Footwear company Skechers is dependent on brick-and-mortar retail, through both its wholesale business and its own stores. That was a problem during the worst of the pandemic in 2020 as retail stores shut down or operated under severe restrictions. Sales plunged 42% in the second quarter of last year, for example, even as e-commerce sales more than quintupled.

The situation has greatly improved for Skechers since then. Fourth-quarter sales were down just 0.5% year over year, and the domestic wholesale business managed to grow slightly. What allowed Skechers to get through this difficult time was an exceptionally strong balance sheet.

Skechers had cash, cash equivalents, and investments of $1.58 billion at the end of 2020, along with total debt of $735 million. That's good for a net cash position of $845 million. For reference, Skechers' market capitalization is currently about $5.8 billion.

A strong balance sheet also helped Skechers be able to invest in its business when times were tough. In the fourth-quarter report, CEO Robert Greenberg said the company was investing in improving its supply chains in the U.S., Asia, and Europe, as well as working on a "roll out of e-commerce platforms around the world."

While Skechers' results may be messy for a while, the company's strong balance sheet will enable it to resume its growth story once the negative effects of the pandemic have passed.

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.