The S&P 500, the Nasdaq Composite and the Dow boasted weekly gains and their longest monthly winning streaks in years.