S&P 500 hits new record, posts best weekly gain since February