Stocks rose on Tuesday on optimism that more financial aid for Greece was imminent, but weaker-than-expected manufacturing and consumer confidence data underscored the headwinds that have hit stocks this month.

The Dow Jones industrial average <.DJI> gained 98.47 points, or 0.79 percent, to 12,540.05. The Standard & Poor's 500 Index <.SPX> gained 9.18 points, or 0.69 percent, to 1,340.28. The Nasdaq Composite Index <.IXIC> gained 20.79 points, or 0.74 percent, to 2,817.65.

(Reporting by Edward Krudy)