Goldman Sachs Group Inc. (GS) - Get Goldman Sachs Group, Inc. (GS) Report  has got its mojo back.

The Wall Street firm, after a worst-in-class trading performance in 2017, has recovered this year with a 24% increase in first-half revenue from its bond, commodities, currencies and stock-trading division. The improvement surpassed a 22% climb at at rival Morgan Stanley (MS) - Get Morgan Stanley (MS) Report , in addition to the other major Wall Street trading firms. At JPMorgan Chase & Co. (JPM) - Get JPMorgan Chase & Co. (JPM) Report , trading revenue rose by 14%, compared with a 6% gain for Bank of America Corp. (BAC) - Get Bank of America Corp Report and 1.1% at Citigroup Inc. (C) - Get Citigroup Inc. Report .

A rebound in the trading business is helping to restore investors' faith in New York-based Goldman as the firm's executives, led by CEO Lloyd Blankfein and President David Solomon, try to shore up a lagging stock price. The firm's shares are down 8.9% this year, the worst showing among the biggest U.S. banks. Even scandal-plagued Wells Fargo & Co. (WFC) - Get Wells Fargo & Company Report has done better, with a stock-price decline of just 6.8%. 

Last month, Goldman faced the added embarrassment of failing a Federal Reserve "stress test" designed to gauge whether big banks could make planned payouts to shareholders via dividends and stock buybacks and still have enough of a financial cushion to survive a severe recession. The Fed agreed to allow Goldman to continue making payouts, while restricting the size of the capital returns to the prior year's levels.

The Wall Street firm's trading results were so horrible last year - total revenue from that business tumbled by 18% -- that Blankfein had to stave off investor pressure by announcing a three-year plan to increase revenue by $5 billion in other areas, partly by lending more to households and businesses.

"Our improvement reflected higher client activity and our efforts to both deepen and broaden our client relationships," Goldman CFO Marty Chavez told analysts on a conference call Tuesday. 

Goldman has also shook up management, announcing the retirement of former Co-President and CFO Harvey Schwartz as well as the departures of two of its three trading co-heads, Pablo Salame and Isabelle Ealet. On Tuesday, the New York-based company announced that Blankfein, 63, would retire at the end of September and be succeeded by Solomon, who's 56.

JPMorgan remains the leader on total revenue from trading, with $14 billion in the first half of this year, followed by No. 2 Citigroup with $9.5 billion and third-place Morgan Stanley with $8.16 billion. On that basis, Goldman was fourth with $8 billion, trailed by Bank of America at $7.5 billion. 

TheStreet Recommends

But Goldman's ability to increase revenue by more than its rivals underscores the resilience of its trading business -- even if last year's abysmal results set a low threshold to beat. 

According to Chavez, Goldman's fixed-income trading in the second quarter improved "significantly" versus the year-earlier period, when its commodities unit suffered from "inventory challenges." 

"The operating environment was more constructive," Chavez said. 

Of course, Goldman still has to prove itself over the rest of the year. 

Some analysts say investors can't rely on Goldman's trading results, since the business is prone to the vagaries of market shifts and client demands, and probably a bit of luck. 

"We still view the revenue beat as not fully sustainable," Brian Kleinhanzl, a banking-industry analyst at the brokerage firm Keefe, Bruyette & Woods, wrote in a report to clients on Tuesday. Kleinhanzl lowered his target price for the stock to $255 from $260. 

But for now, Goldman's trading recovery keeps investor hopes alive. Even Kleinhanzl's lowered price target is still 10% above where the stock is currently trading, about $231. 

"If Goldman Sachs can show that the company will be able to achieve the $5 billion revenue target, without declining revenues elsewhere, then we believe that there would be upside to the earnings and stock price," Kleinhanzl said.