A major measure of U.S. money in circulation -- including hard currency like cash and coins, as well as liquid deposits in bank and money market accounts and some smaller certificates of deposit (CDs) -- recently hit an all-time record. And that could portend trouble for the stock market.

This monetary aggregate is known as M2. And economists watch it very carefully, as it can have a major impact on economic growth, inflation and -- importantly for investors -- the stock market. It recently reached a record $22.2 trillion.

Generally, over the long run, the money supply tends to rise gradually as the economy grows, essentially tracking the value of goods and services the economy produces.

But in the short term, M2 can rise or fall in less stable ways, particularly when the central bank -- in the U.S., the Federal Reserve -- is easing or tightening monetary policy.

Easy money policy

From early 2022 to late 2023, the Fed was tightening monetary policy by raising interest rates in order to combat the runaway inflation that arrived in the wake of the start of the COVID-19 pandemic. That caused the money supply to fall, as the Fed raises rates by selling government securities it holds and soaking up cash from the economy. If people, businesses, and banks have less cash, they tend to spend less or lend less, which gradually slows the pace of economic activity and -- with any luck -- quiets inflation.

M2 began to fall in April 2022 after the Fed began raising rates the previous month. But it's been rising steadily since October 2023, as banks began to expect a resumption of rate cuts by the Fed and started lending more generously.

Banks can lend more money than the deposits they hold -- it's called a fractional reserve banking system. So when a customer is approved for a loan and the money is put into their checking account, that expands the M2 money supply, as M2 includes checking and savings accounts.

Where does all that extra money in the economy wind up?

Well, people become willing to spend more on goods and services when they have more money available. An expanded money supply that is growing faster than economic output means inflation will rise.

Pushing stocks higher

Some of the extra money that isn't spent finds its way into stocks. People with extra cash try to put some of it to work in the market. And that's part of the reason that the market is now at an all-time high.

A trader on the exchange floor cheering.

Image source: Getty Images.

The S&P 500 (^GSPC -2.71%) and the Nasdaq Composite (^IXIC -3.56%) both closed at record highs earlier last week.

That would be fine if the rise in share prices was based purely on an increase in corporate earnings, as, over the long term, share prices track earnings gains. And earnings have generally been very healthy this year. That is expected to continue, with analysts projecting 8% growth in S&P 500 earnings in the third quarter that closed at the end of September.

But that's only part of the story. Investors need to watch valuations, too. That is, they need to be mindful of what they're paying, and comparing stock prices to company earnings, and right now that measure is very high.

Bubble territory

The forward 12-month price-to-earnings ratio for the S&P 500 -- based on estimated earnings -- now sits at 22.8. That ratio hit 25 right before the internet bubble burst in late 1999.

And the cyclically adjusted P/E ratio -- also known as the Shiller P/E ratio, named for Nobel Prize-winning economist Robert Shiller -- is just above 40 at the moment. That's not quite as high as it was in November 1999, just before the internet bubble exploded, when it hit 44. But it's a lot higher than it was in July 1929 on the eve of the Great Crash.

Of course, all factors have to be considered. New innovations like artificial intelligence can send productivity higher, which would merit higher valuations going forward, as companies can create more output with the same -- or even less -- capital, driving earnings higher.

But that's a slower process. Right now, it's pretty clear that the rise in the money supply is pushing stock prices and indexes into bubble territory. And that's a dangerous place to be.