Matt Levine is a Bloomberg Opinion columnist covering finance. He was an editor of Dealbreaker, an investment banker at Goldman Sachs, a mergers and acquisitions lawyer at Wachtell, Lipton, Rosen & Katz, and a clerk for the U.S. Court of Appeals for the 3rd Circuit. Read more opinion SHARE THIS ARTICLE Share Tweet Post Email

Today is the end of the Securities and Exchange Commission's fiscal year, as you might have guessed from the rush of enforcement actions finalized today. I count almost $68 million of penalties coming into the SEC's coffers on the last day of fiscal 2015, from three separate settlements with 25 defendants. One of those settlements was with Latour Trading, the big high-frequency trading firm, for what the SEC calls "market structure rule violations."

A popular story about the speedy computerized modern stock market is that it is dominated by evil high-frequency traders who take advantage of market fragmentation and complexity to rip off mom and pop investors. The particular villains in that story tend to be a bit hazy, but surely Latour is high on the list. Latour, a part of Tower Research, is huge, "opaque," run by an eccentric rich person, and has been in trouble with the SEC before. And is in trouble with the SEC again. Surely if anyone is ripping off mom and pop, it's Latour.

And yet today's enforcement order doesn't support that narrative. It's actually kind of the reverse. Here's the basic story of what Latour did. There are lots of stock markets. Some are big, like Nasdaq and the New York Stock Exchange. Others are teeny, like the Chicago Stock Exchange (CHX), which represents about half of one percent of trading in U.S. equities; "NYSE MKT" (formerly the American Stock Exchange), which represents even less; or the National Stock Exchange (NSX), which represented about 0.2 percent before it gave up and shut down last year.

But even the teeny exchanges are part of the SEC's "national market system," and a cornerstone of that system is the "order protection rule," Rule 611 of Regulation NMS. That rule says that, if you want to buy 100 shares of XYZ stock, and those shares are offered for $10.00 on one exchange, you can't buy them for $10.01 on another exchange. So even though CHX has just a tiny share of the market, you're not allowed to ignore it: If it's got the best price, you have to trade on CHX before going elsewhere.

But let's say you want to buy 1,000 shares of XYZ. You start by buying the 100 shares on offer for $10.00 at CHX, if those are the only shares on offer anywhere for $10.00. Then you keep going. You buy the 200 shares on offer for $10.01 at NYSE, and the 200 shares on offer for $10.01 at Nasdaq. Then you buy the 200 shares on offer for $10.02 on BATS, and the 100 on offer for $10.02 at Direct Edge. Then you buy the 50 for $10.03 at NYSE MKT, and 150 more for $10.03 at Nasdaq. Then you're done.

Hahahahaha no that doesn't work at all! If you actually did that -- buy all the shares at one price on one exchange, then go to another exchange to buy all the shares at the next price, and keep going through all of the 11 exchanges until you've bought all the shares you want -- then, and forgive the language here, high-frequency traders would race ahead of you to change their orders. If you bought some shares on one exchange for $10.00, and then some more on another exchange for $10.01, and then some more on a third exchange for $10.01, then by the time you got to the fourth exchange that $10.02 price wouldn't be there any more. Electronic traders would have figured out that there was a big buyer, and they would have updated their prices to reflect that, meaning that the offers that used to be displayed would disappear before you could access them. By showing your hand like this, you'd drive up the price you'd pay for the shares.

The simple fix is to buy all those shares at the same time: If you know that there are 1,000 shares available at prices from $10.00 to $10.03 on various exchanges, you should try to buy them all at once. But the order protection rule seems to prevent that: If you send an order to NYSE to buy those 200 shares at $10.01, it won't let you trade, because it sees a protected quote for shares available for $10.00 elsewhere.

So there is a slightly more complicated fix, which is that you can buy all the shares at the same time, if you promise all the exchanges that that's what you're doing. This is Rule 611(c) of Regulation NMS, which allows for "intermarket sweep orders." ISOs are sort of an exception to, or a special case of, the order protection rule. If you send an order to all the exchanges at once, and mark it as an ISO, then all of the exchanges know that they're not responsible for worrying about protected quotes. NYSE can sell you those shares at $10.01, because you've promised NYSE that you are simultaneously buying all the shares available for $10.00 at CHX.

But you have to actually do that: You need to send all the orders to all the other exchanges to make sure that you don't trade through any protected quotes. The problem is that Latour messed up this process, in fairly technical and mostly accidental ways.

The main thing it got wrong stemmed from the fact that it was not directly connected to every exchange. The SEC says: "During the relevant time period, Latour was not a member of and thus could not send orders directly to the Chicago Stock Exchange ('CHX'), the National Stock Exchange ('NSX'), and the American Stock Exchange (later renamed 'NYSE MKT')," three exchanges that combined for about 1 percent of equity trading volume. You can see why Latour didn't feel like paying to connect to them. So when it needed to send ISOs to all the exchanges, it couldn't send them directly to CHX, NSX and Amex/NYSE MKT. Instead:

When Latour was required under Reg NMS to send an ISO to one of these exchanges, it sent a “directed ISO” to one of the exchanges operated by BATS Global Markets, Inc. (“BATS”). A directed ISO instructs BATS to route the ISO upon receipt to the exchange specified in the order instructions (in this case, CHX, NSX, or NYSE MKT).

All of this, of course, happened automatically: Latour's algorithms were deciding what to buy, and where, and how, and when they decided to buy shares via an ISO, the algorithms sent out all the instructions. Unfortunately, one day a developer at Tower/Latour was making an unrelated change to the trading software, and saw the code responsible for those directed ISOs, and didn't understand what it did, and just deleted it:

In the course of examining the software code to make the requested change, the Core Engineering developer observed a difference in how the code translated orders to be sent to BATS’ U.S. exchanges as compared to those to be sent to BATS’ European exchange. The developer then eliminated some of the code sequences that he believed created an operational inefficiency. The code sequences that the Core Engineering developer eliminated, however, were crucial to the proper translation of directed ISOs that Latour sent to the trade server application using the new internal messaging protocol. In particular, as a result of the coding change, which went into effect in July 2011, the BATS trade server application dropped the routing destination when it translated any such directed ISO into an order message to send to BATS. The Core Engineering developer did not understand that the changes he made to the code sequences would affect the directed ISOs generated by Latour’s trading algorithms.

Oops! This is a good application of Chesterton's fence: If you work at a high-frequency trading firm, and you don't understand what some code does, don't delete it! Figure out what it does before you delete it.

Latour's other mistake is even more boring and technical than that one. Basically in deciding where to send ISO orders, Latour's algorithms looked to see which exchanges had protected quotes. But Latour knew that sometimes exchanges were slow to update their quotes. If, for instance, NYSE showed an offer for 100 shares at $10.01, and Latour sent an order to buy those shares, and the order came back cancelled because no shares were available, and NYSE still showed that offer, Latour would assume -- not necessarily unreasonably -- that the offer was no longer available (because otherwise its order would have been filled), and that NYSE's data feed just hadn't been updated yet. (All of this is occurring in the space of milliseconds.) And so if it was sending a new ISO a few milliseconds later, it felt free to ignore the protected quote at NYSE, on the assumption that it was a phantom quote that had already vanished. This is actually explicitly allowed by SEC guidance, but Latour accidentally messed it up in really quite eye-glazingly dull ways that I will quote in a footnote for serious masochists.

Here again, notice that the problem Latour was trying to solve was one often noted by critics of high-frequency trading: Market data feeds are sometimes outdated, and the shares that seem to be available often aren't. Latour wanted to buy the shares that the exchanges were offering, but it knew from bitter experience -- the experience of a few milliseconds ago -- that those were phantom offers, and that those shares were no longer available. So it took steps to protect itself against those phantom offers. It messed those steps up a bit, but the intent was not to rip off mom and pop investors. It was to avoid getting ripped off itself.

The thing about Latour is that it is big and does a lot of trades, so when it messed up a few lines of code, it messed up a whole lot of trades. The SEC says:

Latour sent nearly 12.6 million non-compliant ISOs between October 2010 and August 2014. These non-compliant ISOs caused approximately 1.1 million trade-throughs and 1.7 million locked or crossed protected quotations. Latour received $2,784,875 in gross trading profits and exchange rebates from its non-compliant ISOs.

I don't quite know how the SEC measures those ill-gotten gains, but in any case they're pretty small for a firm that accounts for a significant fraction of U.S. equity trading. Tower will have to pay back those gains, plus interest, plus a $5 million penalty, for a total of more than $8 million.

One moral of the story is, of course, be careful with your computer code! But the other is something like: High-frequency trading firms are not so different from you and me and mom and pop. Even the firms whose job it is to understand and deal with and take advantage of market complexity are sometimes confounded by the complexity, the fragmentation and the speed of modern markets.

This column does not necessarily reflect the opinion of the editorial board or Bloomberg LP and its owners.

To contact the author of this story:

Matt Levine at mlevine51@bloomberg.net

To contact the editor responsible for this story:

Zara Kessler at zkessler@bloomberg.net