A Wall Street sign is pictured outside the New York Stock Exchange amid the coronavirus disease (COVID-19) pandemic in the Manhattan borough of New York City, New York, U.S., April 16, 2021.
A Wall Street sign is pictured outside the New York Stock Exchange amid the coronavirus disease (COVID-19) pandemic in the Manhattan borough of New York City, New York, U.S., April 16, 2021. Reuters / Carlo Allegri

U.S. stocks added to their recent rally on Friday after upbeat forecasts from Apple and Amazon.com, and the S&P 500 and Nasdaq posted their biggest monthly percentage gains since 2020.

Most S&P 500 sectors ended higher. Energy was up the most, with Chevron Corp and Exxon Mobil shares jumping after the companies reported record quarterly revenues.

Apple Inc shares rose after the company said parts shortages were easing and that demand for iPhones was continuing. Amazon.com Inc shot up after it forecast a jump in third-quarter revenue from bigger fees from its Prime loyalty subscriptions.

"In today's market, the Amazon and Apple numbers are giving the market support (on) the idea that two large companies that are a large part of the S&P seem so far to be able to navigate through these tougher times," said Rick Meckler, partner at Cherry Lane Investments, a family investment office in New Vernon, New Jersey.

Stocks have also rallied this week on investor speculation that the Federal Reserve may not need to be as aggressive with interest rate hikes as some had feared.

According to preliminary data, the S&P 500 gained 58.05 points, or 1.43%, to end at 4,130.48 points, while the Nasdaq Composite gained 225.81 points, or 1.86%, to 12,388.40. The Dow Jones Industrial Average rose 323.51 points, or 0.99%, to 32,853.14.

In other earnings, Intel Corp shares fell after the company cut annual sales and profit forecasts and missed second-quarter estimates.

Second-quarter U.S. corporate results have mostly been stronger than expected.

Of the 279 S&P 500 companies that have reported earnings so far, 77.8% have exceeded expectations. Earnings for S&P 500 companies now are expected to have increased 7.1% in the quarter versus an estimated 5.6% at the start of July, according to IBES data from Refinitiv.

Data showed U.S. consumer spending increased more than expected in June as Americans paid more for goods and services, with monthly inflation surging by the most since 2005.