Decoded: Breaking down how an actual trading algorithm works. Want to impress your friends? Learn how trading algos work
The next step is sending that list onto an order processing algorithm that goes out and buys or sells the stocks that have been selected.
The code may seem hard to follow, but it's one of the oldest tricks in the "quant" book. The algorithm employs a general statistical arbitrage strategy based on the tendency of overvalued stocks to go back down and the undervalued ones to go up. In the 1970s, 1980s and early 1990s, it could have made a trader millions.
Nowadays, it wouldn't likely earn much at all - it might even lose money - because the opportunity has been largely traded away. That's what makes the markets one of the greatest games - incredibly difficult, but with sometimes huge pay-outs. In some ways, though certainly not in all ways, coming up with a quantitative strategy that makes money is more difficult than the work of a scientist because the laws of physics don't change as physicists make predictions. When an algorithm begins investing money, the opportunity starts to fade instantly. Over time, as others find it, it completely melts away.