Algorithmic trading refers to trade execution strategies typically used by Fund Managers to buy or sell large amounts of assets. They aim to minimise the cost of these transactions under certain risk and timing constraints. Such systems follow preset rules in determining how to execute each order.
But what strategies? How are these preset rules even defined? How can we get an automated system to simply run and make us money? You must first understand the underlying economic theories these rules are based on. After this, you’ll gain an understanding of the basis of various forms of analysis and, subsequently, the foundations of stock evaluation and selection. This all begins with understanding the nature of our financial markets. What drives them, how do they function? Is there a guiding theory that can explain market behaviour to the extent that we can create a predefined set of rules to make profits consistently, and predictable?
Classical finance theory
In 1965, then PhD student Eugene Francis Fama published a paper entitled “The Behavior of Stock Market Prices” that concluded stock market price movements were random.3 There was no predicting them. He followed this up with a 1970 paper describing an efficient market by establishing the efficient market hypothesis.4 Under this hypothesis, market efficiency refers to the situation where the current price of a security reflects all available information about it. Any information you see about a company has already been priced into its stock value. The conclusion of this research is you cannot consistently beat the market, which means stocks always trade at fair value. But how is this possible? The answer is not so much how, but who.
Efficient markets rely on market participants, specifically informed and rational market participants. If an event occurs that has pricing implications for a company’s stock then the market participants will take advantage of this until it has been fully priced in, and is again trading at fair value. For example, if Apple’s stock is trading at £780 (its fair value) and an event occurred that changed its fair value to £600 then traders will begin selling it. The supply of Apple stock will increase causing demand, and subsequently, its price, to drop. This will continue until the stock is trading again at its fair value. Some of these traders will have made a profit above that of the market, but this can’t occur consistently enough to model a winning algorithmic trading strategy around.
Historically in financial markets, the primary form of analysis was fundamental analysis. Fundamental analysis makes use of both financial and economic information to calculate the fair value of a company’s stock. This is the form of analysis market participants use to determine the impact of an event on a stock’s price and then conduct trades until it’s driven back to its fair value.
Behaviour and winning algorithmic strategies
If there is no way to make profits consistently and predictably above that of general market growth the story would end here. But as mentioned earlier, efficient markets rely on market participants – rational ones. Has every person you have met been completely rational? It stands to reason a few unreasonable or overconfident individuals exist as market participants.
Enter behavioural finance
Behavioural finance recognises the inclination of individuals to act irrationally, basing decisions on information they’ve misinterpreted or misjudged. Behavioural finance attempts to make sense of anomalies observed in market behaviour that cannot be accounted for by traditional models. It’s through the understanding of market behaviour that algorithmic trading strategies are formulated and behavioural finance is a theory that must be understood to effectively create a winning algorithmic trading strategy. But you can’t tell a computer to recognise an overconfident person, can you? How can behaviour be used as a base for building a computerised set of rules? The crux is that many people are irrational in the same way, they have similar irrational reactions to certain events. So there is a lot of people acting irrationally together and in a predictable way. This creates patterns in market data that can be targeted consistently and predictably. It may be strange to think of behaviour as a set of statistical indicators, but that’s essentially what behavioural finance aims to achieve.
You can then programme your algorithm to take certain actions based off specific indicators.
We’ve been framed
Our minds are unpredictable at times, we make impulse decisions or base a decision on what’s easiest and quickest. Logically what comes to mind is dependent on an individual’s personal experiences. How information is framed to us can also influence our perception of it. Look at the picture below, when reading the letters the middle character reads as a “B”, but when reading the numbers, the middle character reads as “13”. The letters and then numbers are examples of different ways information can be framed to prompt a specific or desired response.
Our brains crave context, we require it to make an informed decision. If the context is misleading then our interpretation of events may not be completely rational. But what specifically are these irrational behaviours and what causes them? Enter Daniel Kahneman and Amos Tversky. Kahneman is the only non-economist to win a Nobel Prize in economics. Kahneman and Tversky developed multiple strategies around how irrational behaviour is caused and its effect. You can see the effects of this everywhere, whenever you see an advert proclaiming a discount or a huge sale. These attempt to frame information in a certain way to entice a favourable response out of the public (Tversky & Kahneman, 1981).
We’re all biased
Another form of irrational behaviour to review before delving into trade strategy construction, is bias. “Vanilla is the best flavour ice cream” – a great example of bias easy to observe in the market is over and under reaction. Think back to the Apple example, if the market was to overreact to the event that drove its stock price down, investors may think the stock’s fair value is below £600 (its fair value). If this could have been predicted, you could take advantage of this behaviour by simply buying the stock at its devalued price and wait for the market to correct before selling.
There‘s a large body of studies that define an array of irrational behaviours and how these can manifest in financial markets. We’re getting closer to a place that we could base an algorithmic trading strategy on. There’s information on the psychology behind investor decision-making and how this impacts the market. Next the focus is on identifying how biases in the market can be identified using technical indicators. What indicator is an indication that a stock is trading below it’s fair value? This is basically looking for arbitrage opportunities. Arbitrage is the simultaneous purchase and sale of the same, or highly similar, asset in two different markets to take advantage of a pricing difference. So aberrant market behaviour has been identified, as well as a method for profiting off of it. It’s now time to start developing a set a rules the algorithm can follow.
Getting technical in algorithmic trading
The type of analysis that aids you in developing these sets of rules is technical analysis. Technical analysis is the science of predicting stock price movements based on historical market data, it seeks to explain how behavioural traits can be observed in price data. It uses various types of market data to develop signals that can inform your trade strategy. With a good enough signal, you can begin developing a set of rules to base your investment decisions on.
Systematic to algorithmic
Systematic trading refers to the application of a predefined trading strategy (a set of rules) to the process of buying and selling financial securities. Algorithmic trading is a form of systematic trading (basically computerised systematic trading). The systematic approach to trading has been around since before the widespread use of computerised systems. By the 1920s, trading systems were already in place.1 People made use of manual calculations based on charts and data. Traders might have had their weekly data posted to them, or might have collected it from the exchange in person, but now with the aid of computerised computations, these calculations can be done is seconds. There are many forms of algorithmic trading strategies, many are often geared towards taking advantage of small pricing discrepancies, as such they require huge amounts of trades to be executed for significant profits to be made.
Successful high-frequency trading
It should first be understood that high-frequency trading is not a trading strategy in itself, rather it is a mechanism allowing the implementation of certain algorithmic trading strategies. It’s a form of algorithmic trading made up of the frequent turnover of many small positions of a security.
An example of a high-frequency trading strategy is market making. Firms attempt to take advantage of the bid-ask spread. This is the difference between what people are willing to sell the stock for, and what people are willing to buy it for. This is certainly one of the easier strategies to understand. An example is if a firm purchases a stock for £80 (the ask price) and then sells it for £80.05 (the bid price). The difference in price is very small and for this strategy to be effective millions of trades need to be conducted daily. Many of the high-frequency firms are engaged in market making and one of the big challenges these firms face, is intense competition. There could be other more informed counter-parties such as hedge funds or similar trading companies targeting the same market. To be competitive, they need excellent infrastructure and to be very fast. To build a successful high-frequency algorithmic trading strategy it’s important to understand market microstructure. Market microstructure is how markets are designed, how prices are formulated, what the relevant transaction and timing costs are, how information is disclosed, and investor behaviour. If you know what an order book is, you know prices are a product of supply and demand.
High-frequency trading has had several fundamental impacts on our financial markets. It has drastically increased liquidity, and high-frequency traders are credited with providing over 50% of equity turnover in certain markets.2
Real algorithmic trading success
After building your model, it’s essential to test it as thoroughly as possible if you want it to be successful, or at least not lose your capital.
The two primary forms of strategy validation are:
- Out-of-sample testing – to withhold some of the sample data from the model identification and estimation process and then use the model to make predictions for this withheld data.
- Backtesting – a method to simulate a model on historical market data using computers allowing you to test numerous variations of different ideas or models quickly and efficiently, and it provides immediate feedback on how these might have performed in the past.
Out-of-sample testing is crucial for seeing how your model performs on unseen data. If it cannot pass the out-of-sample tests then you need to scrap your model and try again. Do not get too attached to a model, many investors over-fit their models and keep testing until it returns positive results, resulting in a model that might look good in tests but can potentially make you lose a lot of money.
There’s no clearly defined cause and effect for all market movements. When a trading strategy works, it’s not because it perfectly described a mathematical principle, but because it captured a particular market characteristic producing a positive return over time. That needs to be understood, you can never be sure each trade will be a win, but you can be sure that over time your trades will result in a net profit.
There’s no get rich quick scheme here unfortunately, but if you take the time to understand market behaviour and ensure you do due diligence in terms of strategy validation, it’s possible to produce a winning set of rules that can be turned into a winning algorithmic trading strategy.