What's the floating point?
Following on from previous stories about problems related to computational accuracy in financial algorithms, this too is a tale of numerical woe.
Fundamentally, there are two common number formats in computer science: integers and floating point numbers. There are other, less common ways of dealing with numbers inside a computer, but these are not of interest here. For an amusing story about what can go wrong when using integers, the interested reader can refer to the 'No Signal' column in Automated Trader, Issue 39.
Most applications use floating point numbers to represent real numbers. Nowadays, finance is all about squeezing a few basis points (0.0001) from a small rock. This differs somewhat to taking whole (integer) bars of gold, which is apparently what finance used to be. So we often find ourselves dealing with small numbers.
Floating point math comes with a large number of caveats. Few programmers really understand what can go wrong and what they should pay attention to. From rounding issues, to significant digits, to processor and compiler specific problems, it is a veritable minefield for those who are less numerically gifted. There is a standard that is supposed to guide us all - IEEE 754-2008 - but studying this is, in my experience, beyond the ability of most programmers. People just want to get on with calculating stuff, not thinking about the ins and outs of addition or division under the hood.
We'll leave aside the exact nature of rounding issues and problems related to loss of precision and instead focus on what happens when people don't understand the unspecific nature of floating point maths.
A large, unnamed currency hedge fund generated all of its signals through a chunk of legacy code that hadn't changed much since the firm started over a decade ago. The fund was big, and accordingly its signals generated long-term trades.
Long-term signals are usually generated with - drum roll please! - long-term filters. These transform a time series of prices into a slow-moving time series of smoothed data. Common filters include moving averages, Kalman Filters and other, more esoteric menu items (unscented particle filters, anyone?). Quantitative traders are particularly fond of exponential moving averages because they can be cast as a very simple recursive formula: