Getting your Trinity Audio player ready...

Stocks on Thursday closed higher for the first time this week, in a roller-coaster session.

Treasury bonds posted their biggest drop since 2004 after weak bidding at the Treasury’s auction of $9 billion in 30-year bonds. The auction brought a higher-than-expected yield of 4.45 percent, compared with 4.67 percent at the previous auction in November.

The bond sell-off widened the spread between short- and long-term interest rates, a positive sign for bank stocks, which rallied.

Bank stocks were aided, as well, by remarks by Jamie Dimon, chief executive of JPMorgan Chase. Dimon told a conference in Florida that a credit rating downgrade of a bond insurance firm, widely feared on Wall Street, “is not going to be that big a deal for the industry or JPMorgan.” JPMorgan Chase gained $1.39, or 3 percent, to $45.11.

Shares of several retailers advanced, as investors went bargain hunting among the beaten-down sector. J.C. Penney and Gap said fourth-quarter results might beat Wall Street estimates. Penneys added $3.72, or 8.5 percent, to $47.44. Gap rose $1.32, or 7 percent, to $19.65.

The Standard & Poor’s retailing index gained nearly 4 percent.

The Dow Jones industrial average closed up 46.90 points, at 12,247.00, after trading between a 132-point gain and an 80-point loss.

The Standard & Poor’s 500 index added 10.46, to 1336.91. The Nasdaq composite index rose 14.28, to 2293.03. The Russell 2000 index of small-company stocks gained 10.29, to 702.78.

Among local stocks, Chicago-based CME Group rose nearly 9 percent, rebounding a bit from Wednesday’s sell-off of nearly 18 percent. Analysts on Thursday shrugged off antitrust concerns expressed by the Justice Department regarding CME clearing operations.

Crude oil futures rose 97 cents a barrel, to $88.11.