NEW YORK (CNNMoney) -- U.S. stocks closed higher for a third day on Wednesday, as bank shares boosted the broader market following Bank of America's $8.5 billion settlement over mortgage securities claims.
Investors also cheered Greece's approval of austerity measures on Wednesday, which are meant keep the country from defaulting.
"Some of the clouds that have hung over this market have let up," said Bruce McCain, chief investment strategist with Key Private Bank. "The Greek issue isn't resolved, but one forward step was taken and it gets rid of a bit of that uncertainty -- and you can say the same thing for BofA."
The S&P 500 () gained 11 points, or 0.8%, to 1,307; and the Nasdaq Composite ( ) added 12 points, or 0.4%, to 2,740
Shares of Visa (Fortune 500) and Mastercard ( , Fortune 500) were the top performers on the S&P 500, shooting up more than 10%, after the Federal Reserve imposed caps on debit card swipe fees that weren't as high as expected. EBay ( , Fortune 500), which owns PayPal, was up 7%.,
"The mood in the last few days has shifted in the market," McCain said. "You have shares of risk-heavy companies coming back, and there's a return of some optimism among investors -- particularly as the quarter ends this week and we head into earnings season next month."
Greece's vote on Wednesday follows a prolonged debate of whether the country should adopt severe spending cuts and tax increases, in exchange for a financial aid package from the European Union and the International Monetary Fund.
While Greece may have addressed its fiscal situation -- at least for the moment -- there are plenty of other debt-stricken eurozone countries to worry about. And the U.S. economy is still not on solid ground.
"The market hasn't gone anywhere for the last six months, and I can't see any way that we'll break out of this range unless there's significant improvement in growth and employment," said Mic Mills, head of electronic trading at ETX Capital.
Commodities: Energy and metal commodities rallied Wednesday, with oil prices surging after the Energy Department reported a bigger-than-expected drop in oil inventories.
Oil for August delivery settled up $1.88, or 2%, to $94.77 a barrel.
Gold futures for August delivery rose $10.20 to $1,510.40 an ounce; while silver rallied 3.3% to $34.76 an ounce.
Industrial-grade copper futures were also higher, rising 2.9% to $4.21 a pound.
Economy: The National Association of Realtors said that pending home sales rose a better-than-expected 8.2% in May, recovering in part from April's dismal 11.6% decline.
Companies: US Steel ( , Fortune 500) was among the top performers on the S&P 500, rising 6%, after the company was upgraded to "buy" by Deutsche Bank analysts. Competitor AK Steel ( , Fortune 500) also closed sharply higher.
KB Home () shares sank 15%, after the homebuilder reported a second quarter loss.
Monsanto (Fortune 500)'s earnings widely beat expectations, which the company attributed to strength in its seeds business. Shares of Monsanto rose 5%.,
The price on the benchmark 10-year U.S. Treasury edged lower, pushing the yield up to 3.12% from 3.04% late Tuesday.
World markets: European stocks closed sharply higher following Greece's austerity vote. Britain's FTSE 100 rose 1.5%, the DAX in Germany surged 1.7% and France's CAC 40 rallied 1.9%.
|What we want Apple to unveil at WWDC|
|Millennials squeezed out of buying a home|
|7 traits the rich have in common|
|Big Data knows you're sick, tired and depressed|
|Your car is a giant computer - and it can be hacked|
|Overnight Avg Rate||Latest||Change||Last Week|
|30 yr fixed||3.84%||3.80%|
|15 yr fixed||2.95%||2.90%|
|30 yr refi||3.84%||3.81%|
|15 yr refi||3.01%||2.96%|
Today's featured rates: