Stocks Close Off Best Levels on Tech Strength

Stocks closed modestly higher on Wednesday, reversing earlier losses, as investors brushed off ongoing turmoil in Egypt and political uncertain in Portugal and squared positions ahead of the holiday Thursday and jobs report due out Friday morning.

All U.S. markets are closed Thursday for the Fourth of July holiday.

S&P 500

The Dow Jones Industrial Average finished modestly higher as strength in Boeing and Cisco offset weakness in Alcoa following a broker downgrade.

The S&P 500 and the Nasdaq finished higher. The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, traded near 16.

Among S&P sectors, telecoms, techs and consumer discretionary rose, while financials fell.

"We're still in this rough period. We have a 10 percent to 20 percent correction ahead of us later this quarter, early next quarter. For two months now I've been a seller of anything above Dow 15,000 and I'll stay that way," Paul Schatz of Heritage Capital told CNBC.

The day's economic data was largely mixed, providing traders with little direction ahead of the June jobs report due out on Friday.

The ADP employment reportshowed that the U.S. employment rose by 188,000 private-sector jobs in June, while initial jobless claims slipped.

"This would suggest that nothing's changed. The job market is remarkably stable," Mark Zandi, chief economist at Moody's Analytics, told CNBC.

(Read More: Traders Watching Data for Clues to Jobs Report)

Meanwhile, consultants Challenger, Gray & Christmas said the number of job cuts in the first half of the year improved from the first six months of 2012.

Other data was less bright. The U.S. trade deficit widened in May to $45.03 billion from $40.15 billion in April, which could mean downgrades to second-quarter GDP estimates. Already, Goldman Sachs cut its GDP tracking estimate by two-tenths to 1.6 percent.

The ISM non-manufacturing index came in at 52.2, its weakest level since Feb. 2010.

"This market seems to be stuck between expectations of faster economic growth in the second half on the one hand and the threat of the Fed on the other," David Joy, Ameriprise Financial chief market strategist, said. "I think this market is stuck in a trading range until we get a clearer picture."

(Read More: Stocks Start Q3 on Upswing, But Headwinds Coming)

U.S. investors were largely able to brush off weakness overseas sparked by worries about the European periphery and slowing growth in China. China's official service sector Purchasing Managers' Index declined to its weakest level in nine months in June.

Concerns about political instability in Portugal, and debt refinancing in Greece, pressured European stocks with the Portuguese stock market falling 5 percent.

"Markets are speculating about the fate of the (Portuguese) prime minister, and to the extent that this problem reflects concerns over Euro inspired austerity, there are wider implications," UBS global economist Paul Donovan wrote in a note.

U.S. oil prices soared to a 14-month high above $101 a barrel on Wednesday, following a decline in crude stockpiles, and concerns that unrest in Egypt could disrupt oil supplies.

Despite fears of Fed tapering and weakness in global markets, "there's a lot of underlying strength in the (U.S.) equity market," Doug Foreman, co-chief investment officer at Kayne Anderson Rudnick Investment Management, said. "The key questions over the next six to nine months will be does employment continue to improve, does consumer confidence continue to improve, does housing — which is driving the other two — continue to improve."

By CNBC's Justin Menza. Follow him on Twitter @JustinMenza.