US stocks ended a volatile week with a sizable gain as Apple's earnings report boosted technology shares and a smattering of economic data suggested the Federal Reserve is making some progress in its battle against inflation.

The S&P 500 and the tech-heavy Nasdaq 100 both posted their longest weekly gains since August. Gains in major technology companies such as Microsoft and Google Parent Alphabet aided both indexes in reversing a two-day decline.

Treasuries fell on Friday, snapping a three-day rally, as hopes of a Fed pivot faded. The dollar rose for the second day in a row.

This week, stocks, bonds, and the dollar swung wildly as investors tried to make sense of conflicting earnings reports and economic data.

Quarterly reports from megacap tech names underscored the impact of the Fed’s tightening regime, and consequently the surging dollar.

Meanwhile, a core measure of US inflation increased in September, strengthening the Fed's case for another jumbo rate hike next week. However, a contraction in manufacturing and services, as well as lower-than-expected US home sales, indicated that the Fed's actions were already having an impact on the economy. The release of gross domestic product data on Thursday temporarily allayed fears of a recession.

Economists continue to expect the Fed to raise interest rates by three-quarters of a percentage point next week, for the fourth time in a row. Rates are expected to rise another half point in December, followed by quarter point increases in the next two meetings.