Stocks right now are hanging by a thread, boosted by a bonanza of corporate buying unrivaled in market history and held back by a burst in investor selling that also has set a new record.

Both sides are motivated by fear, as corporations find little else to do with their $2.1 trillion in cash than buy back their own shares or make deals, while individual investors head to the sidelines amid fears that a global trade war could thwart the substantial momentum the U.S. economy has seen this year.

"Corporate cash is going to find a home, and it's either going to be in buybacks, dividends or M&A activity. What it's not going to be is in capex," said Art Hogan, chief market strategist at B. Riley FBR. "Individuals are looking at the turbulence we've seen this year that we had not seen last year. That creates its own sort of exit sign for investors who don't want to deal with that."

The numbers showing where each side put their cash in the second quarter are striking.

Companies announced $433.6 billion in share repurchases during the period, nearly doubling the previous record of $242.1 billion in the first quarter, according to market research firm TrimTabs.

Dow components Nike and Walgreens Boots Alliance led the most recent surge in buybacks, with $15 billion and $10 billion, respectively, last week. In all, 31 companies announced buybacks in excess of $1 billion during June.

At the same time, investors dumped $23.7 billion in stock market-focused funds in June, also a new record. For the full quarter, the brutal June brought global net equity outflows to $20.2 billion, the worst performance since the third quarter of 2016, just before the presidential election. The selling is particularly acute in mutual funds, which saw $52.9 billion in outflows during the quarter and are typically more the purview of the retail side.

So far, the market has managed to survive, with a 1.6 percent decline in the first quarter offset by a 3 percent gain in the second quarter, leaving the index up about 1.4 percent for the year.