Automated Day Trading Using Mathematica

Dr. Michael Kelly

Finance Consultant

Abstract

Modern financial exchanges are now equipped to handle trading data with turn around rates of 5 milliseconds. These new conditions mean that only automated pre-programmed trading can hope to succeed in such hyperkinetic conditions. Human beings with slow reaction times, limited calculation skills and an inability to correctly interpret fractal patterns such as time varying trade prices, are hopelessly equipped to deal with such novel situations. We had evolved to pick berries, evade predators and mate, and not to intuit complex mathematical relationships between rapidly varying stochastic processes. The recent financial disaster that sent markets reeling is testament to our hubris in trying to deal with these mutivariable phenomena. That is why computers are necessary to trade and why Mathematica, with its advanced programming language is uniquely capable of providing algorithms to analyze and react to huge quantities of trading data. This short paper will show how Mathematica code was capable of identifying hidden patterns in the dense data and how the Manipulate function was used to illustrate to traders how the program operated throughout the day, including estimates of profit and loss.

The following graph represents 48,000 trading values in an actual hedged trade ZN - β*ZB between ZN, the 10 year note and ZB, the 30 year treasury bond on July 12 this year. Despite optimized hedge ratios (β) that have been chosen to minimize the difference between these two bond prices, the hedged price difference displayed below manifests high volatility. The red dots indicate sales and the blue dots indicate buys, structured so that it never exceeds a maximum position of 3 and never buys or sells when the price difference is less than $50. The net profit on purchases of one lots was $203.