NEW YORK (Reuters) - The S&P 500 and the Dow Jones Industrial Average snapped a three-day run of losses on Friday as optimism about the prospects for a U.S.-China trade agreement countered downbeat U.S. and China manufacturing data.

The Nasdaq meanwhile marked its longest streak of weekly gains since late 1999.

Following President Donald Trump’s announcement last weekend of a delay in higher tariffs on Chinese imports, Bloomberg reported late Thursday that a summit between Trump and his Chinese counterpart Xi Jinping to sign a final trade deal could happen as soon as mid-March.

“The optimism over trade resolution is outweighing the weakening economic data,” said Ryan Detrick, senior market strategist at LPL Financial in Charlotte, North Carolina.

A private survey showed China’s factory activity contracted for a third straight month in February, though at a slower pace, indicating a marginal improvement in domestic demand as a flurry of policy stimulus kicked in from late last year.

ISM data also showed U.S. manufacturing activity for February dropped to its lowest since November 2016, and the University of Michigan survey showed consumer sentiment fell short of expectations in the month.

Detrick said that while the data was weak investors hoped a U.S.-China trade deal would improve global growth prospects.

The Dow Jones Industrial Average rose 110.32 points, or 0.43 percent, to 26,026.32, the S&P 500 gained 19.2 points, or 0.69 percent, to 2,803.69 and the Nasdaq Composite added 62.82 points, or 0.83 percent, to 7,595.35.

Friday marked the first close above 2,800 for the S&P since Nov. 8. Nate Thooft, global head of asset allocation for Manulife Asset Management in Boston said technical investors would see a close above that level “as a good omen.”

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., February 27, 2019. REUTERS/Brendan McDermid

The index closed 4.2 percent under its September record closing high. It has risen 11.8 percent so far this year, bolstered by trade hopes and the Federal Reserve’s cautious stance on interest rates.

For the week, the S&P rose 0.4 percent while the Dow fell 0.02 percent and the Nasdaq rose 0.9 percent.

Of the 11 major S&P 500 sectors, eight were gainers on the day. The healthcare sector rose 1.4 percent, providing the biggest boost and supported by gains in companies including health insurer UnitedHealth Group which bounced back after falling for much of the week.

The consumer discretionary sector rose 0.9 percent, with the biggest lift from Amazon.com.

Foot Locker shares rose 5.9 percent after the retailer beat quarterly same-store sales estimates and helped drive a 1.9 percent gain in shares of Nike Inc, the second biggest boost to the sector.

Gap Inc surged 16 percent, making it the biggest percentage gainer in the S&P, after it said it would separate its better-performing Old Navy brand and close about 230 Gap stores.

The energy sector rose 1.8 percent despite a decline in oil prices. [O/R]

A U.S. Commerce Department report showed inflation pressures remaining tame, which along with slowing domestic and global economic growth, gave more credence to the Federal Reserve’s “patient” stance toward raising interest rates further this year.

Advancing issues outnumbered declining ones on the NYSE by a 1.79-to-1 ratio; on Nasdaq, a 1.86-to-1 ratio favored advancers.

The S&P 500 posted 54 new 52-week highs and no new lows; the Nasdaq Composite recorded 92 new highs and 29 new lows.

Volume on U.S. exchanges was 7.95 billion shares, compared with the 7.27 billion average for the last 20 trading days.