(Reuters) - Big Wall Street banks have spent billions of dollars and untold man-hours in recent years transforming their trading desks from hedge-fund like operations trading on their own account into market-making businesses offering a price based on what customers want to buy or sell.

A Goldman Sachs sign is seen on at the company's post on the floor of the New York Stock Exchange, January 18, 2012. REUTERS/Brendan McDermid

But the shift in business model, prompted by reforms following the 2008 financial crisis, has done little to shield banks from suffering big losses when markets move against them, traders and risk managers told Reuters this week.

Goldman Sachs Group Inc’s GS.N second-quarter results, which saw earnings rise to $3.95 per share from $3.72 in the same quarter last year, also included the worst commodities trading quarter in its history as a public company, prompting a 2.8 percent fall in the bank's stock in the last two days.

Bad inventory positions based on wrong expectations of customer demand were partly to blame, Chief Financial Officer Marty Chavez said.

In explaining the decline in trading revenue, Chavez compared the business to a store that needs to stock the right products on its shelves. It must also be able to absorb what clients are selling and create new products they might want, he said, calling risk management in trading an “art and science.”

Goldman is not alone. In recent years, banks including JPMorgan Chase & Co JPM.N, Citigroup Inc C.N, Barclays PLC BARC.L and Deutsche Bank AG DBKGn.DE have all suffered losses from currency moves, interest rate positions, or misguided bond market bets.

“It’s not always easy to find a ready buyer and seller of the exact same assets that you’re looking for,” said Clifford Rossi, a former risk manager at Citigroup. “There may be timing issues – it’s like musical chairs and the market maker may end up holding whatever is left over.”

Under the so-called the Volcker rule, which was intended to limit proprietary trading, banks are now required to prove they are only holding enough inventory to meet “reasonably expected near-term demand.”

The rule was implemented in response to the 2008 financial crisis, when Wall Street banks fueled problems in the mortgage market by making speculative bets with their own money.

But one of the Volcker rule’s unintended consequences has been to drain liquidity in certain markets, which has made it more expensive and difficult for banks to source inventory for clients or manage their own risks.

New rules defining the amounts of capital banks must hold have made it more expensive for them to hold certain types of assets, while a long period of low volatility in some markets has made it trickier to gauge when trading activity will suddenly rise.

Unexpected gains in the Swiss franc in early-2015 caused losses at Citigroup and Barclays, Reuters reported at the time. Last quarter, Deutsche Bank lost $60 million on a wrong-way inflation bet, according to Bloomberg. JPMorgan lost billions of dollars on the notorious “London whale” trades related to credit default swaps in 2012. In late-2013, Goldman was burned by bad currency bets.

JUST A FLUKE?

In trying to prevent those kinds of losses, banks have developed software algorithms to anticipate market directions, put technology in place so that traders cannot breach risk limits, hired more risk managers, and empowered them to question decisions of dealers.

According to consulting firm Opimas, banks last year spent more than $100 billion globally on management and compliance systems and people.

But ultimately, those investments may prove futile in situations like the one Goldman faced last quarter, when some commodity prices collapsed, volatility in other markets was historically low, and customer activity dropped off. The unexpected trends led the bank’s own commodities research analysts to ask in a June 29 report, “How did we (and the markets) get it so wrong?”

“Throwing more dollars and people on risk management doesn’t necessarily mean there is less trading risk on Wall Street or that it is properly contained,” said Mark Williams, a professor at Boston University’s business school who focuses on risk management in banks.

Goldman has long prided itself on the independence and power of its risk management staff, who are known for questioning high-flying traders without fear of retribution. That helped Goldman become one of the most profitable Wall Street banks, while avoiding many of the pitfalls that beset rivals in the run up to the 2008 financial crisis.

In March, Goldman gave its risk management team even more prominence by moving it into an independent unit.

Some bank analysts are willing to give Goldman a break, given its track record.

“It’s the nature of the business,” said Oppenheimer analyst Chris Kotowski. “It becomes a problem if either it produces massive outsized losses that compromise capital ratios and imperil the company, or they make a habit out of it. It’s too early to say this is a habit rather than a fluke.”