U.S. stocks rallied this week to end trading Friday with the best month since 2020 after tech giants reported better than expected financial results.