By Sinead Carew
(Reuters) – The S&P 500 and the Nasdaq notched record closing highs on Monday, powered by demand for technology stocks after a global cyber attack and by rising oil prices.
Oil rose to the highest level in more than three weeks after top exporters Saudi Arabia and Russia said supply cuts needed to last into 2018, a step toward extending an OPEC-led deal to support prices for longer than originally agreed.
The rising oil prices and housing data drove optimism about the economy and helped make financial stocks <.SPSY> the second biggest driver for the S&P 500, behind the technology sector.
“The oil markets are acting well and that’s helping,” said R.J. Grant, head of trading at Keefe, Bruyette & Woods in New York, who also cited the strong corporate earnings season.
About 75 percent of S&P 500 companies that have reported quarterly results so far have beaten Wall Street expectations, according to Thomson Reuters data.
While data for New York state’s manufacturing sector was weaker than expected, U.S. homebuilder sentiment gave investors some confidence in the economy.
“We need that because there’s been a tug-of-war in this market as to whether this economy is peaking,” Quincy Krosby, market strategist at Prudential Financial in Newark, New Jersey, said, referring to the housing sentiment.
The Dow Jones Industrial Average was up 85.33 points, or 0.41 percent, to the S&P 500 gained 11.42 points, or 0.48 percent, to 2,402.32 and the Nasdaq Composite added 28.44 points, or 0.46 percent, to 6,149.67. Johnson & Johnson & and Cisco Systems were the biggest drivers for the S&P 500 after prominent analysts upgraded their ratings on the stocks.
Shares of cyber security firms jumped on expectations that they would benefit from greater spending after the global “ransomware” attack that began spreading across the globe on Friday. Shares of Fireye rose 7.5 percent, and Symantec and Palo Alto Networks  both gained around 3 percent. The 2.3 percent rise in Cisco was driven in party by its security technology business.
Nine of the 11 major S&P 500 sectors closed higher, with the materials index leading the percentage gainers.
Advancing issues outnumbered declining ones on the NYSE by a 3.10-to-1 ratio; on Nasdaq, a 2.04-to-1 ratio favored advancers.
The S&P 500 posted 46 new 52-week highs and 10 new lows; the Nasdaq Composite recorded 144 new highs and 53 new lows.
About 6.3 billion shares changed hands on U.S. exchanges on Monday compared with the 6.8 billion average for the last 20 sessions.
(Additional reporting by Caroline Valetkevitch in New York, Tanya Agrawal in Bengaluru,; Editing by Alistair Bell and Leslie Adler)