Jail Worthy Computer Code

A little while back I wrote an article about how to design an algorithm generically. I didn’t touch on computer code at all in that article because I was told by a very wise man in the field that algorithms start with a person, and so it makes sense talk about some more of the background of the industry. It’s important to focus on the thought process and the strategy behind the algorithm before you focus on the computer coding. The dream is to have a bit of computer code that will find stocks for you to buy, purchase them, and then sell them for a profit, all while you’re sipping a margarita on a coastal destination. This is called automated trading, black-box trading, or algo-trading.

There was a lot of buzz back in 2010 about algorithm strategies before traders took it a little too far. Generally when Wall Street finds some new technology, new regulation gets pioneered because of the people who took it too far.

For the broader market, there are some dangerous implications here. On May 6th, 2010 we saw one of those implications. Known as the Crash of 2:45, the stock market lost one-trillion dollars in the blink of an eye.

The DOW lost around 10% of its value in a matter of minutes. This was the biggest mid-day stock market loss ever at that point in time. About five years later, 22 criminal counts were laid against a trader name Navinder Sarao. Sarao used a number of high frequency trading techniques in order to profit from a crash in the market. We’re going to talk about a few of them right here, all of which are illegal.


Okay, so spoofing is one way that traders can use the market against itself. If you place a bunch of orders on futures contracts, or short a bunch of equities, the market will react to that because of the efficient market hypothesis. If you place a legitimate long position, and then afterwards place a bunch of long trades (with the intention of cancelling them before execution), these orders will be placed on the order book which can be seen publicly. This is seen by all of the High Frequency Traders with their own set of algorithms. The goal is to trick those algorithms to start trading on this false order book information before the original firm cancels the orders. The HFT’s will jump on board because they think that they’re missing out on the opportunity of a lifetime while all of these long orders execute.

The market could see this, freak out, buy a bunch of shares or contracts and push the price up. Meanwhile, you’ve cancelled all of those long orders, High-Frequency traders are caught holding some overpriced assets, and you sold out of your original long position with a hefty profit.


This is a more specific form of spoofing. Essentially, rather than cancelling these orders, the brokerage makes them without ever intending to execute on them. So these fake orders from layering are often numerous and are supposed to trick the rest of the market in essentially the same way as spoofing. For example, if I wanted to use layering to raise the price of Apple, what I would do is place a bunch of sell orders at rising prices. 1,000 shares at $105.00, 1,000 shares at $105.50, and another 1,000 at $106.00. If an algorithmic trader saw this, they’d jump on board thinking that the stock price was rising. The other algo-trader would jump in front of my orders which would push the price of Apple down to $104.00 which is where I would buy. I have now saved $1.00 on Apple shares just by placing sell orders above price, and an algo-trader has thousands of less valuable Apple shares. This was made illegal by the good ol’ Dodd-Frank act which we’ll talk about in a future article.

Front Running

So you’re a brokerage trying to make some money. You see a bunch of orders come in from an institutional client and you think “man, if I can get a few orders in ahead of that massive order, I can make some money off of the price rise”. So instead of acting ethically and waiting your turn like a gentleman, you place your personal order ahead of the institutional investor’s order and then sell after all the dust settles and make some cash. This is considered stock market manipulation and is pretty bad, so don’t do it. I mean, you probably can’t do it anyway because it requires incredibly powerful computers and network connections near the speed of light, as well as clients with a lot of money.

All of these strategies are illegal because they fall under “market manipulation”. And most people think this only happens in the equity markets, but it also happens in the fixed-income markets too. So now that you know why these things are illegal, you may want to put in some protection for your algorithms if you ever start building some. Some trading firms still have humans execute on the trades, and the algorithm acts just as a screener. That way the human can investigate the signal to make sure it isn’t a false positive. There has been a lot of regulation on this kind of stuff. The Dodd-Frank act came up in 2010 and really took a lot of this manipulative play out of the stock market which is probably a good thing for traders like you and me.


One Comment Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s