At first, this Wall Street Journal story about how some banks lost money in one corner of their energy trading operations struck me as sort of a nothing. All banks always lose money in some corner of their trading operations; they make it up in volume. But if you don't read it as a gotcha, then it's actually a nice story about what banks do and why.

The story is that every year Pemex, the Mexican state oil company, hedges its oil production by entering contracts with banks. I gather that these contracts are mainly floors (put options): Pemex is more or less guaranteed a price of at least, say, $81 a barrel;1 if it can sell its oil for more, it keeps the excess, but if it sells for less than $81, the banks make up the difference. In exchange for this floor, it pays the banks an up-front premium, $450 million in 2013.

Now a lot of oil companies do stuff like this, but typically they trade in contracts that reflect generic oil price benchmarks (Brent, WTI, etc.): They hedge "the price of oil," in some abstract sense, not the exact price that they can idiosyncratically get for their oil. Pemex is a state monopoly with its own particular flavor of oil, and it produces a lot of it, and sets its own price in its own way.2 So it doesn't hedge generically. It hedges the actual price for Pemex oil.

The banks are not in the business of making massive bets on oil prices, so they go and hedge their risk by trading in other oil contracts. Because the market is basically for generic oil price benchmarks, not particular Pemex prices, they trade in futures and options on generic oil contracts. They write a put to Pemex, under which they pay Pemex if oil prices go down, and they hedge that by buying puts or selling futures in the market, and they make money on those hedges if oil prices go down.

The banks have thus, roughly speaking, hedged out their risk that oil prices, all in all, will go down.3

But they still have risks. For instance, they have basis risk, which is a term for, roughly, "the risk you didn't hedge." Pemex prices are not the same as generic oil prices, so hedging Pemex prices using generic oil prices is not risk-free:

Mexican crude "is a difficult one, because there isn't a market hedge you can do to cover it," said John Auers, executive vice president at Dallas consulting firm Turner, Mason & Co. "There's nothing similar to it that has a futures market."

And, apparently, the imperfect hedge that the banks chose turned out to be, in fact, imperfect.4

The two recent losers are Citi and Deutsche Bank (which seems to have lost about $5 million on the trade, which is not that much money), and they seem to have drawn opposite conclusions from the experience:

Citigroup, the third-largest U.S. bank by assets, won a piece of Pemex's oil-hedging program for the first time. The New York company has been working hard to expand its commodity business in the past year as other banks have pulled back.

But:

In fourth-quarter results announced last month, Deutsche cited "significantly lower" commodity revenue; the bank closed its commodity desks in December, though people familiar with the decision said the Pemex trade wasn't a factor in the move.

What conclusions should we draw? I will start by saying: This is a heartwarming story. This is what banks should do. Pemex had a risk and it wanted to hedge that risk. "Hedge a risk" is a very generic statement, but what it means here is that Mexico "relies on oil revenues to fund about a third of its federal budget" and so really needs to know that it can rely on those revenues. So it asks banks to guarantee those revenues.

Now, there is basis risk between Pemex's oil revenues and generic benchmarks of oil prices. This basis risk cannot be avoided, but it can be allocated: Either Pemex can run the risk that its prices won't move in line with world oil prices, or banks can run that risk. There are arguments both ways, but generally the client wants a simple hedge of its actual economic situation, not just a generic market benchmark. And you can certainly read stories about clients taking basis risk that they don't really understand and regretting it.5 Here, Pemex wanted the banks to take the basis risk, so they did. Pemex just got what it wanted, in simple form. The banks had to deal with the costs and risks of constructing what it wanted.

So the banks get points for customer service. It's easy to say that they should lose points for risk management: After all, they lost money. As the Journal says, ominously, "The developments underscore how pitfalls lurk in banks' core business of helping customers manage their risks, and beyond the so-called proprietary trading businesses that regulators have restricted in the wake of the 2008 financial crisis."

Which, true, but those pitfalls are not all bad. There are two ways for banks to take risks from clients. One is by acting as a middleman: The client gives you the risk, and you pass it on to the market. The other is as principal: The client gives you the risk, and you keep it.

These banks did both, and they seem to have done both in roughly the right way. The right way is probably "be as much of a middleman as possible, but no more." Here the banks took all of Pemex's price risk from Pemex, and passed on as much of it as possible to the market, by selling generic crude oil. What they couldn't pass on -- the basis risk between Pemex oil prices and their hedges -- they kept. That risk seems to have cost them millions of dollars, but it's a much smaller risk than the entire oil price risk that they were hedging. Historically, "the price of oil" has been a much more volatile number than "the difference between Pemex's selling price of oil and a basket of oil benchmarks." The banks kept only the latter, smaller risk.6

That's exactly what bank trading operations are supposed to be for: To intermediate liquid generic risks between clients and the markets, and to price and bear illiquid custom risks themselves. Those two things are pretty much the job.

The ways that banks get paid for the intermediation part of the job are pretty straightforward: commissions, fees, bid/ask spreads. The way they get paid for the risk-bearing part of the job is that the risks they take are priced to have positive expectation: You'd expect that, most of the time, these trades will be profitable for the banks.

But there's a lot of variability: That's an expected profit, not a guaranteed one. There's a probability distribution of the actual profits, and it looks a little like this:

Sometimes you'll lose a little money, and then you'll get made fun of, mildly, in the Journal. Sometimes you'll lose a lot of money, and then you'll get made fun of, cruelly, in a Senate hearing. Most of the time you'll make some money and not much will happen. And every so often you'll make a ton of money and people will start raising awkward questions about what you knew and your client didn't.

Given that distribution, it's important to sometimes hear about the losses. They provide a good reminder that when banks talk about being in the business of managing risks for clients, that's really not just code for "taking a lot of money from clients on trades they don't understand." There are real risks, and clients really are shifting them to banks, for a price. Mostly that works out fine, and sometimes it works out terribly for one side or the other, and, sure, the bias is that it's more likely to work out well for the bank than for the client. But that's just a bias, not a certainty, and it's good to sometimes hear about the trades that go the other way. After all, those are the trades that justify the profitable ones.

1 Per the Journal, $81 seems to be the price for 2014. It was $86 for 2013.

2 From the Journal: "Pemex sets the value of its crude using a weighted combination of four other global oil contracts. The number is then adjusted by a discretionary factor that enables Mexico to keep its prices competitive with other sovereign crudes in the region."

3 But not entirely. The Journal implies that some of the losses are driven by declining oil prices, and that might be right. Generically speaking, banks that sell big options to clients tend to hedge by trading in the underlying, because the underlying is more liquid: It is easier to trade large amounts of oil (or oil futures) than it is to trade large amounts of oil options. So if you sell a client a put option on oil prices, you might hedge by selling oil futures. If the price of oil goes down, you owe the client more (on a mark-to-market basis) on the put, but you've made money (on a mark-to-market basis) on the futures you are short. And vice versa.

But this is only true for small price moves. For larger moves, you have to adjust your hedge: If oil prices fall by a lot, the put value will change more than the value of your hedge, and so you need to sell more futures to remain hedged. The more big price moves there are, the worse off you are: Your option and its hedge will be mismatched, and you will have to sell more when prices go down and buy more when prices go up. Buying high and selling low is a bad idea, so you want to do it as little as possible; if your hedging model requires you to do it a lot, then you will be sad, and you will lose money.

(You might recognize some of this from a previous interlude on convertible arbitrage. Convertible arbitrage investors are in the business of (1) buying options and (2) hedging in the underlying stock; they make money when there is a lot of volatility. Banks' commodity hedging desks are in the business of (1) selling options and (2) hedging in the underlying commodity (or its futures etc. equivalent); they're taking the other side of that volatility trade, so they lose money when there is a lot of volatility.)

WTI oil volatility seems to have been lower in 2013 than in 2012, so I'm not really sure why the banks that sold Pemex 2013 oil volatility in December 2012 would have lost money on volatility, but it's certainly possible. The Journal says that, this year, "global oil prices began sliding, intensifying pressure on the banks to protect themselves against potential losses on the Pemex contracts," and you can read that as "... requiring the banks to maintain their hedge by increasing their short positions in oil futures, just as the prices of those futures were going down."

4 Here is a chart, I think:

Looks to my untrained eye like Pemex prices have lost value relative to WTI benchmark prices, which would suggest that the banks have lost money on their basis risk: They are long Pemex oil (by being short a put), and short benchmark oil.

5 Municipalities that issued floating-rate bonds linked to the Sifma index, and hedged them with Libor-linked swaps, are a classic recent case. That went poorly for those municipalities, in part because the basis really moved, and in part because Libor (and thus the basis) was manipulated.

6 Honestly I have no way of knowing whether they hedged as much as possible and kept only the basis (and volatility) risk, or actually leaned into this position. It's a complicated question; it's model-based, you have a whole book that you hedge, plus nothing is really disclosed. The point is that the losses were pretty small: Deutsche Bank is said to have market-to-market losses of $5 million. Pemex paid $450 million of premium for these options in 2013; $5 million in losses doesn't look so big against that number.

To contact the writer of this article: Matt Levine at mlevine51@bloomberg.net.

To contact the editor responsible for this article: Tobin Harshaw at tharshaw@bloomberg.net