Tuesday, February 28, 2012

Weird stuff in high frequency markets

On the left is a graph from a really neat paper, "Low-Latency Trading" by Joel Hasbrouck and Gideon Saar (2011). You're looking at the flow of "messages"--limit orders placed or canceled--on the NASDAQ.  The x axis is time, modulo 10 seconds. So, you're looking at the typical flow of messages over any 10 second time interval.

As you can see, there is a big crush of messages on the top of the second, which rapidly tails off in the milliseconds following the even second. There is a second surge between 500 and 600 milliseconds.

Evidently, lots of computer programs reach out and look at the markets once per second, or once per half second. The programs clocks are tightly synchronized to the exchange's clock, so if you program a computer "go look once per second," it's likely to go look exactly on the second (or half second). The result is a flurry of activity on the even second.

 It's likely the even-second traders are what Joel and Gideon call "Agency traders." They're trying to buy or sell a given quantity, but spread it out to avoid price impact. Their on-the-second activity spawns a flurry of responses from the high frequency traders, whose computers monitor markets constantly.

There's a natural question: Is this an accident, or is there intentional "on the second" bunching? You can see that a programmer who didn't think about it would check once per second, not realizing that means exactly on the top of the second. But sometimes there is more liquidity when we all agree to meet at the same time. Volume has always been higher at the open and close.  Joel and Gideon show the pattern lasted from 2007 to 2008, so was not an obvious short-term programming bug.  (Do notice the vertical scale however. The range is from 9 to 13, not 0 to 13.) I'd be curious to know if it's still going on.

Here's another one, found by one of my students on nanex.net here. (Teaching has many benefits when the students know more about markets than you do!).

You're looking at bids, asks, and (white dot) trades in the natural gas futures markets. From nanex:

On June 8, 2011, starting at 19:39 Eastern Time, trade prices began oscillating almost harmonically along with the depth of book. However, prices rose as bid were executed, and prices declined when offers were executed .....price oscillates from low to high when trades are executing against the highest bid price level. After reaching a peak, prices then move down as trades execute against the highest ask price level. This is completely opposite of normal market behavior....It's almost as if someone is executing a new algorithm that has it's buying/selling signals crossed. Most disturbing to us is the high volume violent sell off that affects not only the natural gas market, but all the other trading instruments related to it.
I'm generally give efficient markets the benefit of doutbt, but it's hard not to suspect that some programming bugs are working against each other here. It's hard enough to debug a program to work alone, but when 17 programs work against each other all sorts of interesting weirdness can spill out. I am reminded of work in game theory in which computer programs fight out the prisoner's dilemma and all sorts of weird stuff erupts. If so, this will settle down, but it may take a while.

The Economist reports an interesting related story.
ON FEBRUARY 3RD 2010, at 1.26.28 pm, an automated trading system operated by a high-frequency trader (HFT) called Infinium Capital Management malfunctioned. Over the next three seconds it entered 6,767 individual orders to buy light sweet crude oil futures... Enough of those orders were filled to send the market jolting upwards.
A NYMEX business-conduct panel investigated what happened that day.... Infinium had finished writing the algorithm only the day before it introduced it to the market, and had tested it for only a couple of hours in a simulated trading environment to see how it would perform. .... When the algorithm started its frenetic buying spree, the measures designed to shut it down automatically did not work. One was supposed to turn the system off if a maximum order size was breached, but because the machine was placing lots of small orders rather than a single big one the shut-down was not triggered. The other measure was meant to prevent Infinium from selling or buying more than a certain number of contracts, but because of an error in the way the rogue algorithm had been written, this, too, failed to spot a problem. ..
High frequency trading presents a lot of interesting puzzles. The Booth faculty lunchroom has hosted some interesting discussions: "what possible social use is it to have price discovery in a microsecond instead of a millisecond?" "I don't know, but there's a theorem that says if it's profitable it's socially beneficial." "Not if there are externalities" "Ok, where's the externality?" At which point we all agree we don't know what the heck is going on.

There is also the more prosaic question whether high frequency traders "provide liquidity" and thus are in some sense beneficial to markets, or if they are somehow making markets worse. A question for another day (there is some interesting new research).

There are lots of reports of how profitable it is. But high frequency trading is a zero sum game. Anything you do in milliseconds can only talk to another computer. By definition, they can't all be making money off each other.