The Gateway to Algorithmic and Automated Trading

Sex, death and the quest for algorithmic glory

Published in Automated Trader Magazine Issue 29 Q2 2013

You don't need to look far to find critics of artificial intelligence methods in financial markets. But that hasn't stopped technologists and academics from trying to push the boundaries of what a computer can do when trying to analyse complex situations and make decisions. Automated Trader Editor Adam Cox talks to some of the researchers and executives who see a future for AI in the markets.

Christopher Clack is sitting in a noisy university cafeteria and what he really wants to talk about is sex. In this case, however, he means sex between consenting computer programs.

Clack is describing to Automated Trader his research in genetic programming at University College London in order to determine what combinations of factors will form the best financial models.

chris clack

Christopher Clack

Genetic programming - or GP - is a Darwinian evolution technique that creates an artificial version of survival of the fittest, where solutions (programs) that work well get to survive and have 'sex' with other good solutions to create a child solution that inherits characteristics from both parents. The successful parents and the children stay in the computational gene pool to battle it out again with other solutions in future generations. Solutions that prove less successful simply die off. Since sex and death are two drivers of evolution, the idea of GP is that you can 'evolve' your way to optimum models - after thousands of simulated generations, the computational gene pool is full of very successful solutions.

Clack, who runs a financial computing programme, is one of a growing number of academics and technology executives who are hunting for successful ways to use artificial intelligence methods in finance. It's a far cry from the pulpy plotline of 'Fear Index' by Robert Harris or the ghost-in-the-machine scare tactics of Hollywood blockbusters such as 'I Robot'. The reality in the halls of academia and meeting rooms of tech firms is much less dramatic, with progress coming in fits and starts and resembling nothing like the sleek images of science fiction thrillers. But these researchers are optimistic that they are making genuine headway, even if many don't even like using the much-hyped term AI.

"AI, artificial intelligence, as a term is problematic for two reasons," Clack said. "First, it's been around for too long with too many links to science fiction, overblown expectations and disappointments. Second, it means too many different things to different people - even amongst scientists there are deep divisions between different types of AI research."

Whatever baggage may come with the term, there's little doubt that some companies are serious about AI's potential to make or save investors' money, either by generating trading signals or on the execution side.

Soldiers of fortune

Tucker Balch, like Clack, has an academic pedigree. In addition to an executive role at a tech company he co-founded, he's an associate professor in computational finance at Georgia Tech. Years ago he was working on a project commissioned by the US military.

"What I had built was a system for the Department of Defense that allows a soldier in the field to drive a robot around with a remote control and the robot observes what the soldier's telling it to do," Balch said.

"It thinks, 'Hmmm, I see this set of obstacles in front of me and the human drove me this way'. It remembers all that and then later when it's allowed to run by itself, it sees what's in front of it, looks up in its memory to find the closest situation it has seen before and does what the soldier had told it to do before."

Getting the robot to learn from the past was one breakthrough. Seeing what that meant in other fields was another. "I realised about six years ago that these same sorts of algorithms also make perfect sense for trading and investing."

Fast forward, and he is now chief technology officer of Lucena, which is marketing three AI-based products. One of them generates five-, 10 and 20-day price forecasts for about 13,000 equity symbols in North America. The product uses the same sort of technology as the robotic companion of the soldier in the field.

Lucena Forecaster

Lucena Forecaster

Lucena Back Tester

Lucena Back tester

"It's a giant database and it looks for situations that are similar for a stock today that have occurred in stocks in the past. So we use several factors - for instance, they might be technical indicators like Bollinger bands or MACD. And we look back in time: when were these factors similar to what they are today for this stock, and when they were similar, how did the price change going into the future?"

Lucena went live with its products last December in a web-based format, and it has launched the line-up on the Bloomberg platform. Balch said the target market is small hedge funds that want scientific validation of their strategies, as well as investment and wealth management advisors who want to attract more assets using modern tools.

The soldier's friend makes it all sound so easy. Just remember what the human did and do likewise in similar situations. The reality is a more complex affair.

Balch said there are some 30 data items including price, volume and fundamental data which together produce about 180-200 different indicators. An example of a fundamental data item might be the number of days since the last quarterly report. Out of those different indicators, the Lucena system arrives at about 10-15 factors to make forecasts for the coming week and it continues to review the full 200 to see if any shuffling of indicators needs to be made. Clients can also override the default model and select their own indicators.

Lucena uses several machine-learning algorithms, including genetic algorithms. They also use KNN, or k-nearest neighbour, a pattern recognition algorithm used for classifying objects based on the closest training example, and decision trees.

Researchers using GP have found their methods themselves needed to evolve to help them produce robust models.

The first issue is the question of how a solution is determined to be 'good' (meaning it survives and gets to mate) or is 'bad' (meaning it dies). In GP research, this is called the Fitness Function, and it can be complex. In Clack's research, the solutions are the factor models - arithmetic equations containing names of financial factors such as earnings per share, the three-month moving average, or book value - and the Fitness Function is itself an entire investment simulator which back-tests a single solution against years of financial data. Clack characterised the system as "a simulator inside a simulator", with the back-testing being run perhaps millions of times during evolution.

"The problem in the past with AI technology for finance was that a program - say, a factor model - would do very well and be very profitable for several weeks, and then the market regime would change and you'd discover that that particular equation, that factor model, was well-suited to the previous regime but wasn't as well suited to the new regime," Clack said.

"It could be as simple as a change from a bull to bear market," he said. "It could be going from a low interest rate regime to a high interest rate regime."

In GP, two key problems have been over-fitting and premature convergence. For overfitting, if one chooses the very best solution from the final gene pool it might be so closely optimised to the historical data that it fails when real data is slightly different. This problem can generally be addressed, but a more difficult challenge comes from premature convergence, which is where evolution converges too early on a sub-optimal solution.

One way to address the premature convergence issue that Clack identified came from going back to nature. A healthy population, he said, needs diversity.

"One of the things my research did was to look not just at diversity in the genetic material but also at the diversity in the dynamic behaviour of the solutions", he said. "We're interested in how to use diversity not only to avoid premature convergence, but also to evolve solutions that continue to perform well when there is a change in market regime."

In terms of a factor model, that could mean which factors were being used, how they were being combined, whether they were being added or divided, and so on.

To continue the metaphor, the same genes can end up expressing themselves differently - producing a different phenotype in biological terms - in different environments. Whereas in nature, that environment might be the Sahara or the Arctic, in markets it could mean a low or high interest rate regime.

"So the proof of whether this technique works actually is in how much money it makes," Clack said. "What we're looking for is a factor model that will behave well in both the Sahara and in the Arctic and in rain forests."

As for overfitting, this is an issue that gets raised frequently by AI sceptics.

"All machine learning and AI techniques assume that there's something there and we just have to find what it is," Balch of Lucena said. "But when we observe the world and the way it acts, there's some kind of additional noise that's added on top of what the stocks are doing that sort of blurs our vision into what that true underlying behaviour is."

When a model is overfitting, he said, it means the model is matching more of the noise than the underlying behaviour.

But how do you know if you're overfitting? Change the parameters of the model, or the factors, and see how noisy the results are, Balch said.

"For instance, one of the parameters that we change is how many factors do we use," he said. "As you slowly change the parameter, the value that you're measuring also slowly changes, and that's an indication that you're not overfitting. But if, as you're changing one of these parameters, the value that you're measuring changes wildly, that means that the relationship is sort of unstable. And if you make a decision based on that relationship, you're likely to be overfitting."

Another option: limit how much of the data a system is allowed to look at when it is being trained.

"So a typical approach is to only allow your system to look at half of the data. You refine it and optimise it so that it works well on that half of the data and then you test it on the other half," Balch said. "And if the predictability is retained when you make that test, it's telling you that your model does not overfit the data. So we do that when we're developing strategies; we follow that method of only testing over part of the data and then we check it on the other part."

Such data restrictions can be applied to the range of symbols a model is using or the period of time it covers. "So as an example, we often train our systems in 2007-2008 and then test them in 2009," he said.

Mimicking the trader

Alfred Eskander Portware

Alfred Eskandar, Portware

What springs to mind for many when you talk about artificial intelligence is the task of coming up with alpha-generating trading signals. But one technology vendor has chosen to use the techniques for a different part of the trade cycle.

Portware had been building custom trading systems for about a decade when Alfred Eskandar joined them in March 2012 as chief executive officer. In that time, Eskandar said, the company had developed a stable of strong selling points: an open architecture, global reach and a multi-asset class, broker-neutral approach.

"The one ingredient that was missing was some sort of advanced analytic," he said.

"Having spent many years with traders, particularly on the buy side, it just occurred to us that we needed to help traders make informed decisions faster to keep pace with the speed at which trading and information flows."

The decisions he means are not for what to buy or sell and at what levels, but how to execute those orders once a trading decision has been taken.

Portware finished beta testing on its new product, called Alpha Vision, in the fourth quarter of last year. The idea is that it tries to learn from each small execution of a parent order and is constantly testing results against an initial execution hypothesis, making corrections along the way.

"What tweak do I need to make, what change should I get into? Should I pause, should I go faster, should I go slower? What tactics should I be in now?"

In a perfect world, a trader would babysit an order and watch every tic or piece of information to make adjustments in the algorithm to capture as much of the alpha as possible.

But Eskandar said it can be overwhelming for a trader trying to process all the information flowing through the market in order to make on-the-fly execution decisions.

"Imagine if you have to trade 50 orders and now there are 50 different conditions for each order, that's just an enormous amount of change that needs to be monitored and responded to."

At the same time, there are fewer traders on desks and they're being asked to do more. "So their time per decision is actually going down," he said.

Like the signal-generating AI systems, Alpha Vision uses a range of factors to help it make decisions. Eskandar said there about 45 different ones which essentially mimic what a good trader would look at. As an order is dribbled out, the system is considering all the different factors for possible adjustments if the results do not match a hypothesis.

"It sounds exhaustive or unmanageable to a human being but it's not to a server," he said.

Eskandar said that so far the system has executed 1.4 billion of trades, partnering with seven different OMs and EMS vendors, with 10 institutional clients and 11 broker dealers. During those trades, the algo optimisation engine switched an order on average of 42 times per completion, he said. "An average trader will do that three to four times in the lifespan of an order."

Eskandar said that unlike typical 'black box' solutions, the product allows a user to see the decision-making process.

"A lot of these black box models are just simply that, they're black box models," he said. "There's no interaction with the trader, there's no communication with the trader. It's essentially predictive models working without any feedback to the trader, spitting out an end result. But traders need a whole lot more than that. They need colour, they need information in real time as these things are happening to give them confidence and decision support."

Michael Kampouridis of the University of Kent also stressed the value of transparency, although his work concerns trading decisions not execution, as in the case of Portware.

Kampouridis has been researching the use of GP using a tool called EDDIE, or the Evolutionary Dynamic Data Investment Evaluator. He looks into the periods of pre-specified indicators - some of the various moving averages that traders frequently use, for instance - and probes what happens to performance when other values are considered.

He then looks at the discrepancies that arise, and tries to find what works best using GP and another technique called hyper heuristics, which is a method that attempts to solve problems by automating the selection and/or adjustment of simpler heuristics.

"The idea that you can dynamically select those indicators … that is the main advantage," Kampouridis said. "And then, if I can question pre-specified [time] periods, I can also question the indicators themselves. I can allow GP to evolve and create functions by itself."

As a 'white box technique', this method creates decision trees allowing a trader to visualise the trading strategies and gain insight into how predictions were made.

Meanwhile, AI-based technology is also making its way into more behind-the-scenes aspects of the market infrastructure.

Jock Percy, chief executive officer at Perseus Telecom, said that as his company adds wireless connectivity to its fibre networks, it is interested in how AI technology can determine when to switch over at the optimum moment to avoid network failure between two mediums.

"Before it happens we're evaluating how we plug AI into that process, so that we can look at the weather conditions across our entire network and make smart decisions from those conditions on at what point we switch seamlessly to fibre," he said.

"What we're seeing in the telecoms industry is more software-defined networking."

The average switch hit, the term for when something fails, is about 50 milliseconds, he said. "You and I know what could happen in 50 milliseconds. The market could have moved a mile."

'Not for the faint of heart'

The advent of viable AI systems in markets has been possible because of transformative improvements in computational power, internet speeds and database technology, allowing researchers to try methods that previously would not have been feasible commercially.

"Some of the algorithms we use have been around for a long time but they would have essentially had to run on the mainframes in the back room at a big investment house. Nowadays, we can make these computations quickly enough that we can deliver it to many clients," Balch of Lucena said.

"Some of the computations we're doing involve at least millions, and often billions, of data points that we access and process very, very quickly."

But none of that came easy, researchers and executives said.

Balch said the software that Lucena provides was the result of four years of work by five people.

And Eskandar is not too concerned about companies quickly crowding into his space.

"It's a combination of lots of hardware, software and sophisticated predictive models," he said. "This is not for the faint of heart, and is not something that can be pulled together with a couple of servers."