The Nasdaq closed at a record high for the second day in a row with help from the technology and consumer discretionary sectors, while the S&P 500 edged higher as investors eyed solid US economic data.

However, bank stocks declined along with US Treasury yields, and investors appeared to favour bonds over defensive equity sectors such as utilities and consumer staples.

Services sector data

The US services sector activity accelerated in May, pointing to robust economic growth in the second quarter, although trade tariffs and a shortage of workers posed a threat to the outlook.

“The economy continues to be a very strong foundation for the stock market. What seems to be concerning markets today is the possibility for a slowdown outside of the United States,” said Tracie McMillion, head of global asset allocation strategy for Wells Fargo Investment Institute, in Winston-Salem, North Carolina.

Political stability in Italy

Investors were hoping for signs of political stability in Italy as the new, anti-establishment government won its first vote of confidence in the upper house Senate and the Prime Minister promised radical changes, including more generous welfare and a crackdown on immigration.

“Investors are worried about a slowdown in growth in emerging markets and concerned about Italy being able to stabilise its government. The confidence vote should help,” said McMillion.

The Dow Jones Industrial Average fell 13.71 points, or 0.06 per cent, to 24,799.98, the S&P 500 gained 1.93 points, or 0.07 per cent, to 2,748.8 and the Nasdaq Composite added 31.40 points, or 0.41 per cent, to 7,637.86.

The Nasdaq's biggest boost was from Amazon.com , which rose 1.9 per cent, also leading gains in the S&P consumer discretionary index. Apple rose 0.8 per cent, contributing the biggest point gains to the technology index and the second biggest for the Nasdaq.

The Cboe Volatility Index, the most widely followed barometer of expected near-term volatility for the S&P 500, closed down 0.34 point at 12.4, its lowest close since January 26.

The financial sector was the S&P's biggest drag with a 0.4 per cent decline. Bank of America and Citibank fell around 0.9 per cent. Banks often trade in line with Treasury yields as higher rates can boost their profits.

Liz Ann Sonders, chief investment strategist at Charles Schwab Corp in New York, pointed to “very good” US non-manufacturing data released Tuesday but highlighted a ”pretty big jump” in the prices paid index, which rose to 64.3 in May from 61.8 in April.

“We are starting to see signs inflation is gaining traction,” Sonders said.

Twitter shares closed up 5.1 per cent on news that the social media company would join the benchmark S&P 500 US index, while Netflix rose 1.1 per cent after news it would enter the S&P 100 index.

Shares of US packaged food companies fell as Mexico imposes tariffs on sensitive agricultural products from pork to bourbon as well as certain types of cheeses. Kellogg and General Mills each fell around 2 per cent.

Advancing issues outnumbered declining ones on the NYSE by a 1.43-to-1 ratio; on Nasdaq, a 1.79-to-1 ratio favoured advancers.

The S&P 500 posted 50 new 52-week highs and eight new lows; the Nasdaq Composite recorded 223 new highs and 39 new lows. Volume on US exchanges was 6.58 billion shares, compared with the 6.64 billion average for the last 20 sessions.