Stocks closed out a rocky second quarter with solid gains as banks led indexes higher and more in Friday’s Stock Market Update.

A wave of selling swept over the market for most of this week as traders shifted money to less risky holdings like U.S. government bonds while remaining cautiously optimistic about this weekend’s meeting in Japan between President Donald Trump and President Xi Jinping of China.

Investors are hoping the talks put the world’s two biggest economies on track to resolve their trade dispute, which has led to costly tariffs imposed by both countries on each other’s goods. Wall Street is worried the fallout from the tariffs could hurt global economic growth and corporate profits.

“You’ve been seeing markets lean in this sort of optimistic direction on trade,” said Brian Nick, chief investment strategist at Nuveen, noting that the possibility of a trade deal and a Federal Reserve rate cut have been priced into the market. “It’s hard to see how we’re actually going to earn our way higher from here.”

Banks led the way higher after the Federal Reserve late Thursday approved plans by the country’s 18 biggest banks to return more money to shareholders. The approvals were part of the Fed’s annual checkup of the banking system. JPMorgan Chase rose 2.7% and Bank of America climbed 2.8%.

Industrial and energy stocks also notched strong gains. Union Pacific rose 1.8% while oil companies including Chevron and Exxon were broadly higher.

Technology stocks lagged the most, weighed down by 1.7% drop for Cisco Systems. Apple fell 0.8% following the departure of its highly regarded chief of design, Jony Ive.

Health care stocks also declined, led by a 2.4% drop in Biogen. UnitedHealth Group also fell, losing 0.9%.

STOCK MARKET UPDATE

KEEPING SCORE: The S&P 500 index rose 16 points, or 0.6%, to 2,941. The benchmark index ended a roller-coaster second quarter with a gain of 3.8%. It’s up 17.3% for the year. The Dow Jones Industrial Average rose 73 points, or 0.3%, to 26,599. The Nasdaq added 38 points, or 0.5%, to 8,006.

Smaller company stocks were big gainers for the second straight day. The Russell 2000 index climbed 1.2%.

Major stock indexes in Europe rose.

JUNE JUMP: June marked a sharp about-face from May, when traders fled to safer holdings because of increased anxiety over trade disputes and global economic growth. The S&P 500 reached a record closing high on June 20, though it has retreated slightly from that mark.

JULY HEAT: Investors are heading into the first week of July closely watching for any developments from trade talks between the U.S. and China. Trump and Xi will meet this weekend in Japan, marking their first meeting since the trade war escalated following 11 rounds of negotiations.

Trade-war induced volatility isn’t going anywhere soon and investors are going to have to come to terms with that, said Kristina Hooper, chief global market strategist at Invesco.

“Investors need to recognize that the trade situation is unlikely to improve,” she said. “The best we can hope for is an agreement to continue talks.”

STRESS RELIEF: Bank stocks gained ground after they were given the thumbs up by the Federal Reserve to give investors more cash.

JPMorgan, Bank of America, Wells Fargo and others all passed the most recent round of “stress tests” meant to assess whether they could survive a sudden economic downturn. They were mandated following the Great Recession a decade ago.

The results mean that banks can raise their dividends and buy back more shares this year and still have enough capital to survive a hypothetical deep recession in the next year.

KEEPING IT REAL: Secondhand-fashion online retailer RealReal jumped on its first day of trading.

The company, which offers a marketplace for discounted Gucci and other luxury goods, surged 44.5% after its IPO hit the market at $20 per share. The San Francisco company trades on the Nasdaq under the “REAL” ticker.

CERVEZA, POR FAVOR: Constellation Brands climbed 4.6% after raising its profit forecast for the year following a blowout fiscal first quarter financial report.

The company toppled Wall Street’s profit and revenue forecasts for the quarter as customers tapped into more of the company’s Modelo Especial. Overall beer sales rose 7.4%, driven by Modelo. Constellation recently sold some of its lower-end wines as it focuses more on its premium wine options and its beer sales.

© The Associated Press. All rights reserved.