Investors bailed out of U.S. stocks at a near-record pace in the last week, as money flowing into Treasury bills surged to a 10-year high.

Outflows from U.S. stock funds and ETFs totaled $24.2 billion, the third-highest ever, and the $30 billion that came out of global stock funds in total in the past week was the second-highest ever and largest since the financial crisis, according to Bank of America Merrill Lynch strategists. The outflows from U.S. stocks were the highest since the stock market correction in February. Bonds, at the same time, saw small inflows of $700 million.

"That nervousness, the losses people were experiencing in non-U.S. markets with the trade wars has probably led to what you're seeing in the markets in the last week or so — a big unwind of positioning, a flight to quality," said Michael Hartnett, BofAML chief investment strategist.

Hartnett said there was a "pervasive euphoria" about the U.S. at the beginning of the year and that has faded. Now, investors are adjusting positions, not panicking, though T-bills, considered the safest of safe haven bets, continued to pull in funds at a rapid pace.

"It's not like it's February 2016. It's not like we're staring recession in the face, and everyone is cashed up to the eyeballs and policymakers are panicking. That's not what's happening. It's just that people were pricing in Goldilocks forever earlier on in the year, and that was wrong. They're probably unwinding that positioning," he said. "It helps explain why the markets have firmed up in the last couple of days. You want to buy fear and sell greed."

Hartnett said July could be a month where investors sell volatility, but then the market could get rockier in August and September, ahead of the midterm elections.