NEW YORK (MarketWatch) — The dollar rose for a 10th session on Friday -- its longest rally since 2008 -- after data showed U.S. consumer sentiment unexpectedly improved this month, offsetting worries stirred by J.P. Morgan Chase & Co.’s surprise trading loss.

A lack of resolution in Greece’s political leadership and worries about Spain’s banks continued to weigh on the euro.

The ICE dollar index DXY, +0.26% , which measures the U.S. unit against a basket of six currencies, traded at 80.296 from 80.159 late Thursday — its longest winning streak since an 11-day run in August 2008, as the U.S. credit crisis heated up.

Hopes raised in Greek coalition talks

The euro EURUSD, -0.40% also swung between slight positive and negative territory, lately buying $1.2920, down from $1.2943 in late North American trading Thursday.

For the week, the euro has lost 1.3%, finally breaking below $1.30 for the first time since January.

The dollar index has advanced for a second week, by 1%, as elections last weekend in France and Greece stirred worries that Europeans are becoming tired with the austerity measures forced upon them to address sovereign debt problems.

“Last weekend’s elections were finally the catalyst that pushed the euro dollar out of its range,” said John Doyle, director of markets at Tempus Consulting. “We saw a wave of anti-austerity sentiment and have to ask how is that going to affect other southern European countries.”

Spanish 10-year yields (10YR_ESP) also touched 6% this week and European economic data showed countries struggling to grow.

“Things are still rosier on this side of the pond,” Doyle said. “We’re bullish on the dollar medium-term, but it’s going to take a while.”

A positive U.S. economic report Friday feeds into that longer-term lean toward the dollar.

Reuters

The University of Michigan-Thomson Reuters consumer sentiment index climbed to 77.8 in May, up from 76.4 in April, above the 76.0 expected in a MarketWatch-compiled economist poll. Read about consumer sentiment.

That briefly turned U.S. stocks higher, but the S&P 500 Index SPX, -0.48% turned down 0.3% by just before the close of trading.

Investors’ appetite for risk took a hit starting late Thursday after J.P. Morgan JPM, -0.84% announced that it faced a loss of roughly $2 billion on trading in credit derivatives. Read story on J.P. Morgan.

The euro had little immediate reaction to the Spanish government’s announcement of reforms for its banking sector that include raising loss provisions on loan portfolios, according to reports. See more on Spanish banks.

Investors also continue to watch developments in Greece, where party leaders remain engaged in talks in an effort to cobble together a coalition government in the wake of last Sunday’s splintered election results.

“Investors should not mistaken the lack of further weakness for renewed optimism,” said Kathy Lien, director of currency research at GFT. “The Greeks are still having a tough time forming a coalition government.”

Reports about Spain are also limiting the shared currency’s decline, she said.

The greenback gained a little after a U.S. report showed producer prices unexpectedly fell 0.2% in April. Read story on PPI.

U.K. pound, Canadian dollar

Also Friday, the British pound GBPUSD, -0.31% retreated to $1.6076, down from $1.6156 Thursday.

The greenback turned sharply lower against the Canadian dollar after a government report showed Canada’s economy added way more jobs in April than analysts expected. See blog on how good Canada’s jobs report was.

The dollar traded at 79.94 Japanese yen USDJPY, +0.01% , from ¥79.99 late Thursday.