In the last 15 minutes of the trading session, United States stocks managed to erase many of the day’s losses. This advance sent the Standard & Poor’s 500 index into its second consecutive week of gains. Over the week, the Standard & Poor’s 500 index rose by 0.5 percent. For the month, it advanced by 0.4 percent. The past few weeks have been marred by dramatic swings in the stock market. Every time an official comments on the progress of a budget agreement, the market changes course.