U.S. stocks closed slightly higher on Wednesday, as fresh inflation data reinforced investor hopes that the Federal Reserve is done raising interest rates, while retail stocks were boosted by an upbeat forecast from Target .

Shares in Target surged 17.8% in its biggest one-day percentage gain since August 2019 after the retailer forecast a fourth-quarter profit largely above expectations on easing supply-chain costs.

Target's bright outlook lifted shares of other retailers including Macy's, which rose 7.5%, and Kohl's, which closed up almost 9%. The S&P 500 consumer staples index , which includes Target, was the top sector gainer, adding 0.7%.

Stocks had rallied on Tuesday after a softer-than-expected consumer price index (CPI) reading boosted optimism that the Fed might be able to avoid raising rates further.

Additional data on Wednesday showed the biggest decline in producer prices in 3-1/2 years in October on the back of cheaper gasoline, offering more evidence of easing price pressures.

Also on Wednesday, retail sales data showed a smaller-than-expected decline of 0.1% in October, against forecasts of a 0.3% fall, according to economists polled by Reuters.

"Those two data points reaffirmed the message from Tuesday that the Fed seems to be navigating the soft landing quite well," said Ronald Temple, chief market strategist at Lazard.

After the big move by Wall Street's three major indexes in the previous session, Temple said Wednesday's data "doesn't change the narrative."

The Dow Jones Industrial Average rose 163.51 points, or 0.47%, to 34,991.21, the S&P 500 gained 7.18 points, or 0.16%, at 4,502.88 and the Nasdaq Composite added 9.46 points, or 0.07%, at 14,103.84.

The benchmark S&P 500 and tech-heavy Nasdaq had posted their biggest daily percentage gains in more than six months on Tuesday, after the consumer prices data.

Among the S&P 500's 11 major sectors energy was the biggest decliner, down 0.3%, followed closely by utilities . After consumer staples, communications services advanced the most, with a boost from Walt Disney . The entertainment company rose 3% after reports that activist investor ValueAct Capital had acquired a stake.

The Russell 2000 index again advanced, after closing 5.4% higher on Tuesday, as the prospect of stalling rate hikes provides particular relief to smaller companies, which are more dependent on floating rate loans.

Money market traders have fully priced in odds that the U.S. central bank will keep rates steady in December, as per CME Group's Fedwatch tool. They also see the first rate cut of the cycle kicking off in May 2024.

Investors were also watching for the outcome of the first meeting in a year between U.S. President Joe Biden and Chinese leader Xi Jinping on Wednesday, hoping the talks could ease friction between the superpowers on military conflicts, drug-trafficking and artificial intelligence.

Further aiding the mood, the U.S. House of Representatives passed a temporary spending bill that would avert a government shutdown, with broad support from lawmakers from both parties.

To prevent a shutdown, the Senate and Republican-controlled House must enact a legislation that Biden can sign into law before current funding for federal agencies expires at midnight on Friday.

Among individual stocks, retailer TJX's shares fell 3.3% after it forecast current-quarter profit below Wall Street expectations, signaling spiraling costs weighing on margins.

Sirius XM shares rallied 6% after Warren Buffett's Berkshire Hathaway took a stake in the audio entertainment company.

On U.S. exchanges 11.67 billion shares changed hands, above the 11.15 billion average for the last 20 sessions.

Advancing issues outnumbered decliners on the NYSE by a 1.36-to-1 ratio; on Nasdaq, a 1.32-to-1 ratio favored advancers.

The S&P 500 posted 42 new 52-week highs and no new lows; the Nasdaq Composite recorded 106 new highs and 89 new lows. (Reporting by Sinéad Carew in New York, Sruthi Shankar and Amruta Khandekar in Bengaluru; Editing by Shinjini Ganguli, Maju Samuel, Pooja Desai and Richard Chang)