The S&P is on its best streak in two months. Investors have become more confident about the economy after a strong June jobs report. The index is up 2.9 percent in July after falling 1.5 percent in June, its first monthly decline since October.
Investors are watching earnings results for the second quarter, which ended 10 days ago. Analysts expect earnings growth to average 2.8 percent for companies in the S&P 500, according to data from S&P Capital IQ.
The expected growth is not spectacular and that makes it more likely that companies could beat analysts' estimates, said Eric Wiegand, senior portfolio manager at U.S. Bank Wealth Management. "We have very low expectations," Wiegand said.
Family Dollar Stores was a case in point. The discount retailer said Wednesday that its quarterly earnings fell 3 percent. But earnings topped analysts' estimates, and the stock surged $4.55, or 7.1 percent, to $68.50, making it the biggest gainer in the S&P 500.
Dollar General was the second-biggest gainer in the index, rising $2.98, or 5.75 percent, to $54.78.
The yield on the 10-year Treasury note rose to 2.68 percent from 2.64 percent late Tuesday. As recently as early May, the yield was 1.63 percent.
The price of crude oil jumped almost 3 percent to the highest level in 16 months after the U.S. government reported another steep decline in the nation's supplies. Oil rose $2.99 to $105.71 a barrel in New York.
The price of gold rose $1.5, or 0.1 percent, to $1,247.40 an ounce.