To enjoy the full Mail & Guardian online experience: please upgrade your browser
11 Mar 2015 00:00
Algorithms generated by computers that use artificial intelligence could revolutionise the buying and selling of stocks at bourses around the globe. (Lucas Jackson, Reuters)
How can we use machine intelligence to optimise trading on stock exchanges and teach learning machines to minimise the costs incurred by traders and investors?
My research comes at a time of heightened South African interest in this field, following the relocation of the JSE’s servers from London to Johannesburg in July 2012, and a significant change in the JSE’s billing model in September 2013, paving the way for low-latency, automated trading strategies.
I am a PhD candidate in the University of the Witwatersrand’s school of computational and applied mathematics, where I am using reinforcement learning to teach machines how to break large share trades into smaller trades, so that each transaction can be performed at the smallest possible cost in the market.
This research forms part of a larger initiative, driven by my supervisor, Professor Diane Wilcox, and by Dr Tim Gebbie, senior lecturer in computational and applied mathematics.
This initiative aims to understand the structure and behaviour of the stock markets in the Brics countries (Brazil, Russia, India, China and South Africa) and other emerging markets in micro-timescales as infrastructures become more sophisticated.
Here is how it works.
The stock market consists of buyers and sellers willing to transact at various prices in varying quantities.
Limit-order marketBuyers and sellers can place orders in the market at prices and quantities of their own choice, creating a so-called “limit-order market” for a stock. If a buyer’s order matches a seller’s order in terms of price, then a trade takes place through a “limit-order match”. If any buyers do not want to wait to be matched by a seller, they can choose to trade immediately, given the current “sell limit orders” – but this will incur an additional cost.
This is best explained by way of an example. Let’s say a buyer wants to purchase 500 shares for R100. The buyer has two options: either the buyer tries to get his desired price by placing a limit order in the market or absorbs the necessary available sell orders by executing a market order.
Let’s consider the implications of a market order. On the other side of the limit-order book, the first seller may be willing to sell 100 shares for R105, the second seller may be willing to sell 300 shares for R110 and a third seller may be willing to sell 100 shares for R115.
The buyer can get his or her entire desired quantity of 500 shares by immediately matching each of these sell orders, but the effective trading price will be R110 (which is calculated using a simple volume-weighted average). So to get the shares immediately, it becomes necessary to pay only R10 more than originally hoped.
However, instead of buying the shares all at once, the buyer can elect to purchase them in smaller packages – say, 100 shares at a time. The first 100 shares will then be purchased at R105, incurring a cost of R5 more.
By the time the second transaction takes places, a number of things may have occurred to change the state of the market.
New sellers may have entered the market or previous sellers may have come down in price.
Cost savingTherefore, it might be possible to purchase the second package of 100 shares for R105 rather than R110, and so on. The overall cost would then be R105, resulting in a cost saving of R5.
This approach also helps to avoid a situation in which the purchase of a large number of shares in a single transaction signals their attractiveness to the market: an action that could drive up the price and result in transactions at even higher prices.
Traditionally, traders split the large transaction (parent) into many smaller parts (children), using their specialised insight and experience of market dynamics.
Our research at Wits shows that machines can be taught to perform aspects of this function, and at faster reaction rates than human traders can achieve.
We use reinforcement learning, a form of machine learning traditionally used in the robotics domain, to get a machine to perceive the state of the market and choose the best possible action (“child-order size”) to minimise trading costs, and then learn from that action to refine its decisions further over time.
An additional facet of our research involves a novel approach to model the temporal states of the stock market by using clustering techniques. This is particularly relevant for high-frequency markets, where complications arise from features of the limit-order book changing rapidly and asynchronously.
Improving trading performanceA better descriptor, which can detect the market’s state nearly in real time, would mean a trading agent could adapt better to changing regimes and still improve trading performance. It may also reveal market regimes that require intervention, which human traders may not have foreseen.
Our research is now very relevant because of two critical changes to the JSE. First, the execution speeds are 400 times faster than was previously possible as a result of the relocation of the JSE’s servers to Johannesburg in July 2012. This means that it is now technologically feasible to deploy low-latency, automated strategies, which are used in international markets such as the United States, the United Kingdom, Europe and Asia.
Second, the change in the JSE’s billing model in September 2013 removed a “floor” for the transaction fees paid to the exchange. This floor comprised a minimum cost payable for trades below a certain value, which meant that splitting larger trades into many smaller trades was sometimes unprofitable.
The removal of this floor resulted in fees that are purely value-based (up to a certain ceiling), so smaller trades incur commensurately smaller fees. This means that these strategies are not only possible, but also profitable on the local exchange.
With the increased level of higher-frequency algorithmic activity on the exchange, we require trading algorithms that can adapt and react at micro-timescales.
At the moment, I am focused on continuing my research and have published one peer-reviewed paper, with another under review and several more planned.
I have presented parts of this research at international conferences, including those held by the prestigious Institute of Electrical and Electronics Engineers in London, Mathematics in Finance in South Africa and the Society for Industrial and Applied Mathematics in Chicago. In collaboration with Wilcox and Gebbie, our research group aims to explore various aspects of stock market behaviour at micro-timescales.
The development of adaptive trading machines in high-frequency markets presents many challenges. First, we had to describe how to apply this technique to trading, which was the first output from this work, because it had been tried before but in a slightly different way. We then had to investigate the proposition of using clustering to describe market states, before focusing on the speed of calculations to make the algorithm a “near-real-time” one. Each step has made its own contribution.
Dieter Hendricks is a PhD candidate in the University of the Witwaters-rand’s school of computational and applied mathematics
Create Account | Lost Your Password?