(Bloomberg) -- Apple Inc. is close to erasing its losses for the year as softer-than-expected inflation data fueled a risk-on rally in the stock market Wednesday. 

The iPhone-maker edged 2.6% higher to $169.24 as investors piled back into stocks on bets the Federal Reserve could dial back the size of future interest-rate hikes, after the July consumer price index showed a deceleration in growth from the prior month. Megacap tech stocks all rallied with Meta Platforms Inc. and Netflix Inc. leading the pack on a more than 5.8% gain each, while the Nasdaq 100 Index advanced 2.9%. The tech-heavy benchmark closed 20% higher from its June low.

Since bottoming in mid-June, Apple’s shares have surged about 30%, outpacing the S&P 500 Index and the Nasdaq 100. That’s put the tech giant back on top as the world’s most valuable company and within reach of turning positive for the year. It is now down just 4.7% in 2022, compared with a drop of 18% for the Nasdaq 100. 

The furious rally comes after the company posted quarterly earnings that were better-than-feared, and also reflects Wall Street’s confidence in its ability to continue churning out big profits. Individual investors, who recently helped ignite rallies in speculative corners of the market, have also flocked to the stock. 

Apple, which has a market value of about $2.7 trillion, surpassed oil giant Saudi Aramco again in July to become the world’s largest company. 

The recent surge puts its shares back in the expensive camp, trading at 26.4 times profits projected over the next 12 months, well above its 10-year average at 16.7 times. That compares with the Nasdaq 100 which is priced at 23 times earnings and the S&P 500 at 17.8.

About 96% of analysts covering the stock recommend investors buy or hold on to their positions, according to data compiled by Bloomberg, with an average forecast of a 6.9% gain in its shares over the next 12 months.

(Updates share price moves.)

©2022 Bloomberg L.P.