Professional investors have suddenly turned optimistic about U.S. stocks again, with bullish sentiment fed by an especially buoyant earnings season that is offsetting other concerns.

Domestic equities are holding the biggest portfolio weight since January 2015, according to the August Bank of America Merrill Lynch Fund Managers Survey, a look at where 243 pros who manage $735 billion are putting their money.

The shift in position away from global equities comes even though U.S. stock returns in 2018 have been relatively meager — the Dow Jones Industrial Average is up just 1.9 percent year to date though the broader S&P 500 has gained 5.6 percent.

Investors have been impressed with the profit boom this year. With second-quarter earnings season almost over, S&P 500 companies collectively are on track to show a 24.6 percent gain from the same period a year ago as 79 percent have beaten Wall Street profit estimates, according to FactSet.

However, Michael Hartnett, BofAML's chief investment strategist, said the rise in sentiment is a cautionary sign as central banks continue to gradually tighten policy and expectations are that the profit boom will tail off due to tougher comparisons ahead.

"Rising corporate leverage concerns say bonds should outperform stocks, while a weaker profit outlook suggests defensives could outperform cyclicals," Hartnett said. "With investors telling us they are long the US, the Fed and cash, our view remains: peak profits, policy and returns."

The market has had plenty to worry about this year, from the global trade war to rising interest rates and signs from government bond yields that the next recession could be a year or so away. However, the U.S. economy has proved resilient and is, in fact, outpacing much of the developed world.

Still, investors remain concerned even amid the big overweight for U.S. stocks.

Cash has risen to 5 percent of portfolios, up from 4.7 percent in the past month and ahead of the 4.5 percent 10-year average. Managers consider the trade war to be the biggest "tail risk," while 32 percent think that the U.S. economy, which boasted a 4.1 percent GDP gain in the second quarter, faces deceleration ahead.

Investors also are betting against bonds as the Fed raises interest rates, which they think will continue. They also still see the bet on technology's biggest names — the "FANG" and "BAT" stocks — as the most crowded trade.