# Beware the Algorithm

High-speed trading in financial markets is processed by algorithms deciding when and how to make purchases and sales at over a hundred thousand trades per second.  These algorithms exploit small price differences between markets and in theory synchronise prices to a “true” value.

Change always brings risk.  In August 2012, a change in the New York Stock Exchange rules to allow shares to be offered more cheaply to the public went live one month after it had been announced.  One firm, Knight Capital, rushed to update its existing algorithms to take advantage of the change.  The algorithm started buying shares across 154 companies but it was buying them at a higher price than it could sell them.  One hour after starting, the firm shut down its trading having made a loss of \$461m in that hour.  Apparently, the changed algorithm activated some old testing code – allegedly a single line of code.  The firm was bailed out in return for 73% of its stock – three-quarters of the company gone in one hour because of one line of code.

The world’s most expensive book was a 1992 academic text on genetics called The Making of a Fly.  It was listed on Amazon at \$23,698,655.93 (plus \$3.99 postage).  The Making of a Fly was available for sale in the U.S. from only two book sellers: Bordeebook and Profnath.  Sellers can set a price algorithmically on Amazon and Profnath set the rule as something like “make the price of my book 0.07% cheaper than the next cheapest price”.  Bordeebook wanted to be more expensive and set their rule as something like “make the price of my book 27% more than the next cheapest option”, as some buyers think a higher price equals better quality or more likely to deliver.

Because there were only two sellers in the market, the algorithms went into a vicious circle continuously ratcheting up the price.  If say, the price of the cheaper one had been set at a \$100 (this is an academic textbook), then the algorithm for the second one would have kicked in setting its price at \$100 x 1.27 = \$127.  This would then have caused the cheaper one’s price to be re-set at \$127 x 0.9983 = \$126.80 which then caused the second one to increase to \$126.80 x 1.27 = \$161.03, and so on, eventually exceeding \$23m.

Neither of the algorithms had an upper limit for the price, and nobody noticed other than a few bemused geneticists.  One of the sellers finally saw what was happening and put a stop to it.

If the price tag on a book has to reach \$23m before a malfunctioning algorithm is picked up, how many smaller algorithmic malfunctions might be going unnoticed every day with as yet unknown consequences?

Data Source: Humble Pi – a comedy of maths errors, Matt Parker