‘Looks can be deceiving,’ a wise person once said. The phrase holds true for Algorithmic Trading Strategies. The term ‘Algorithmic trading strategies’ might sound very fancy or too complicated. However, the concept is very simple to understand, once the basics are clear. In this article, We will be telling you about algorithmic trading strategies with some interesting examples.
If you look at it from the outside, an algorithm is just a set of instructions or rules. These set of rules are then used on a stock exchange to automate the execution of orders without human intervention.
This concept is called Algorithmic Trading.
Popular algorithmic trading strategies used in automated trading are covered in this article. Learn the basics of Algorithmic trading strategy paradigms and modelling ideas.
- Classification of Algorithmic Trading Strategies, Paradigms & Modelling Ideas
- Market Making
- Machine Learning In Trading
- Options Trading and Options Trading Strategies - What Are They?
- Building And Implementing Algorithmic Trading Strategies
- Bonus Content
- What’s Next?
All the algorithmic trading strategies that are being used today can be classified broadly into the following categories:
- Momentum-based Strategies or Trend Following Algorithmic Trading Strategies
- Arbitrage Algorithmic Trading Strategies
- Statistical Arbitrage Algorithmic Trading Strategies
- Market Making Algorithmic Trading Strategies
We will be throwing some light on the strategy paradigms and modelling ideas pertaining to each algorithmic trading strategy.
Assume that there is a particular trend in the market. As an algo trader, you are following that trend.
Further to our assumption, the markets fall within the week. Now, you can use statistics to determine if this trend is going to continue. Or if it will change in the coming weeks. Accordingly, you will make your next move.
You have based your algorithmic trading strategy on the market trends which you determined by using statistics.
This method of following trends is called Momentum-based Strategy.
There are numerous ways to implement this algorithmic trading strategy and I have discussed this in detail in one of our previous articles called “Methodology of Quantifying News for Automated Trading”
Strategy paradigms of Momentum-based Strategies
Momentum Strategies seek to profit from the continuance of the existing trend by taking advantage of market swings.
“In simple words, buy high and sell higher and vice versa.”
And how do we achieve this?
- Short-term positions: In this particular algorithmic trading strategy we will take short-term positions in stocks that are going up or down until they show signs of reversal. It is counter-intuitive to almost all other well-known strategies.
- Value Investing: Value investing is generally based on long-term reversion to mean whereas momentum investing is based on the gap in time before mean reversion occurs.
- Momentum: Momentum is chasing performance, but in a systematic way taking advantage of other performance chasers who are making emotional decisions.
Explanations: There are usually two explanations given for any strategy that has been proven to work historically,
- Either the strategy is compensated for the extra risk that it takes, or
- There are behavioural factors due to which premium exists
Why Momentum works?
There is a long list of behavioural biases and emotional mistakes that investors exhibit due to which momentum works.
However, this is easier said than done as trends don’t last forever and can exhibit swift reversals when they peak and come to an end.
Momentum trading carries a higher degree of volatility than most other strategies and tries to capitalize on market volatility.
It is important to time the buys and sells correctly to avoid losses by using proper risk management techniques and stop losses. Momentum investing requires proper monitoring and appropriate diversification to safeguard against such severe crashes.
Modelling ideas of Momentum-based Strategies
Firstly, you should know how to detect Price momentum or the trends. As you are already into trading, you know that trends can be detected by following stocks and ETFs that have been continuously going up for days, weeks or even several months in a row.
For instance, identify the stocks trading within 10% of their 52 weeks high or look at the percentage price change over the last 12 or 24 weeks. Similarly to spot a shorter trend, include a shorter term price change.
eg. If you remember, back in 2008, the oil and energy sector was continuously ranked as one of the top sectors even while it was collapsing.
Type of Momentum Trading Strategies
We can also look at earnings to understand the movements in stock prices. Strategies based on either past returns (Price momentum strategies) or on earnings surprise (known as Earnings momentum strategies) exploit market under-reaction to different pieces of information.
- Earnings Momentum Strategies: An earnings momentum strategy may profit from the under-reaction to information related to short-term earnings.
- Price Momentum Strategies: A price momentum strategy may profit from the market’s slow response to a broader set of information including longer-term profitability.
eg. If we assume that a pharma-corp is to be bought by another company, then the stock price of that corp could go up.
This is triggered by the acquisition which is a corporate event. If you are planning to invest based on the pricing inefficiencies that may happen during a corporate event (before or after), then you are using an event-driven strategy.
Bankruptcy, acquisition, merger, spin-offs etc. could be the event that drives such kind of an investment strategy. These arbitrage trading strategies can be market neutral and used by hedge funds and proprietary traders widely.
When an arbitrage opportunity arises because of misquoting in prices, it can be very advantageous to the algorithmic trading strategy. Although such opportunities exist for a very short duration as the prices in the market get adjusted quickly. And that’s why this is the best use of algorithmic trading strategies, as an automated machine can track such changes instantly.
For instance, if Apple‘s price falls under $1 then Microsoft will fall by $ 0.5 but Microsoft has not fallen, so you will go and sell Microsoft to make a profit.
You can also read about the common misconceptions people have about Statistical Arbitrage.
Strategy paradigms of Statistical Arbitrage
If Market making is the strategy that makes use of the bid-ask spread, Statistical Arbitrage seeks to profit from statistical mispricing of one or more assets based on the expected value of these assets.
A more academic way to explain statistical arbitrage is to spread the risk among thousand to million trades in a very short holding time to, expecting to gain profit from the law of large numbers. Statistical Arbitrage Algorithms are based on mean reversion hypothesis, mostly as a pair.
Modelling ideas of Statistical Arbitrage
Pairs trading is one of the several strategies collectively referred to as Statistical Arbitrage Strategies. In pairs trade strategy, stocks that exhibit historical co-movement in prices are paired using fundamental or market-based similarities. The strategy builds upon the notion that the relative prices in a market are in equilibrium, and that deviations from this equilibrium eventually will be corrected.
When one stock outperforms the other, the outperformer is sold short and the other stock is bought long, with the expectation that the short term diversion will end in convergence. This often hedges market risk from adverse market movements i.e. makes the strategy beta neutral.
However, the total market risk of a position depends on the amount of capital invested in each stock and the sensitivity of stocks to such risk.
Some important reads:
- Arbitrage Strategies: Understanding Working of Statistical Arbitrage
- Kalman Filter Techniques And Statistical Arbitrage In China’s Futures Market In Python
To understand Market Making, let me first talk about Market Makers.
According to Wikipedia:
A market maker or liquidity provider is a company, or an individual, that quotes both a buy and sell price in a financial instrument or commodity held in inventory, hoping to make a profit on the bid-offer spread, or turn.
Market making provides liquidity to securities which are not frequently traded on the stock exchange. The market maker can enhance the demand-supply equation of securities.
Let me give you an example:
Let’s assume you have Martin, a market maker, who buys for INR 500 from the market and sell it at INR 505. He will give you a bid-ask quote of INR 505-500. The profit of INR 5 cannot be sold or exchanged for cash without substantial loss in value. When Martin takes a higher risk then the profit is also higher.
I found Michael Lewis’ book ‘Flash Boys’ in Indian Bull Market pretty interesting and it talks about liquidity, market making and HFT in great detail. Check it out after you finish reading this article.
Since you will need to be analytical & quantitative while getting into or upgrading to algorithmic trading it is imperative to learn to programme (some if not all) and build foolproof systems and execute right algorithmic trading strategy.
Reading this article on Automated Trading Systems: Architecture, Protocols, Types of Latency will be very beneficial for you.
Strategy paradigms of Market Making
As I had mentioned earlier, the primary objective of Market making is to infuse liquidity in securities that are not traded on stock exchanges. In order to measure the liquidity, we take the bid-ask spread and trading volumes into consideration.
The trading algorithms tend to profit from the bid-ask spread.
eg. We will be referring to our buddy, Martin, again in this section. Martin being a market maker is a liquidity provider who can quote on both buy and sell side in a financial instrument hoping to profit from the bid-offer spread. Martin will accept the risk of holding the securities for which he has quoted the price for and once the order is received, he will often immediately sell from his own inventory. He might seek an offsetting offer in seconds and vice versa.
When it comes to illiquid securities, the spreads are usually higher and so are the profits.
eg. Martin will take a higher risk in this case. Several segments in the market lack investor interest due to lack of liquidity as they are unable to gain exit from several small-cap stocks and mid-cap stocks at any given point in time.
Market Makers like Martin are helpful as they are always ready to buy and sell at the price quoted by them. In fact, much of high frequency trading (HFT) is passive market making. The strategies are present on both sides of the market (often simultaneously) competing with each other to provide liquidity to those who need
So, when is this market making strategy most profitable?
This strategy is profitable as long as the model accurately predicts the future price variations.
Modelling ideas of Market Making
The bid-ask spread and trade volume can be modelled together to get the liquidity cost curve which is the fee paid by the liquidity taker. If the liquidity taker only executes orders at the best bid and ask, the fee will be equal to the bid-ask spread times the volume. When the traders go beyond best bid and ask taking more volume, the fee becomes a function of the volume as well.
Trade volume is difficult to model as it depends on the liquidity takers execution strategy. The objective should be to find a model for trade volumes that is consistent with price dynamics.
Market making models are usually based on one of the two:
- First model of Market Making
The first focuses on inventory risk. The model is based on preferred inventory position and prices based on the risk appetite.
- Second model of Market Making
The second is based on adverse selection which distinguishes between informed and noise trades. Noise trades do not possess any view on the market whereas informed trades do. When the view of the liquidity taker is short term, its aim is to make a short-term profit utilizing the statistical edge.
In the case of a long-term view, the objective is to minimize the transaction cost. The long-term strategies and liquidity constraints can be modelled as noise around the short-term execution strategies.
To know more about Market Makers, you can check out this interesting article.
Some important reads:
- Introduction to Market Making & High Frequency Trading Strategies
- Market Microstructure Explained
- Using Quadratic Discriminant Analysis To Optimize An Intraday Momentum Strategy
You might feel that if you have limited knowledge of the topics like Market Making, Market Microstructure or the forthcoming topics, you might have to explore what will help you gain skills to master these. Rachel Tan, a working professional gained this knowledge and all the relevant skillsets through the Executive Programme in Algorithmic Trading (EPAT). Here's what she has to say.
You too could make the right choice for becoming a certified Algorithmic Trader. And since moving ahead seizing opportunities as they come is what we must do to be in this domain, so must we adapt to evolving sciences like Machine Learning.
In Machine Learning based trading, algorithms are used to predict the range for very short-term price movements at a certain confidence interval. The advantage of using Artificial Intelligence (AI) is that humans develop the initial software and the AI itself develops the model and improves it over time.
A large number of funds rely on computer models built by data scientists and quants but they’re usually static, i.e. they don’t change with the market. Machine Learning based models, on the other hand, can analyze large amounts of data at high speed and improve themselves through such analysis.
Modelling idea for Machine Learning in Trading
A form of machine learning called “Bayesian networks” can be used to predict market trends while utilizing a couple of machines. You can read all about Bayesian statistics and econometrics in this article.
An AI which includes techniques such as 'Evolutionary computation' (which is inspired by genetics) and deep learning might run across hundreds or even thousands of machines.
What can this AI do?
- It can create a large and random collection of digital stock traders and test their performance on historical data.
- It then picks the best performers and uses their style/patterns to create a new of evolved traders.
- This process repeats multiple times and a digital trader that can fully operate on its own is created.
These were some important strategy paradigms and modelling ideas. Next, we will go through the step-by-step procedure to build an algorithmic trading strategy.
You can learn these Paradigms in great detail in one of the most extensive algorithmic trading courses available online with lecture recordings and lifetime access and support - Executive Programme in Algorithmic Trading (EPAT).
Some important reads:
- Trading Using Machine Learning In Python
- Free Resources to Learn Machine Learning for Trading
- Machine Learning for Quants and Traders
- Optimal Portfolio Construction Using Machine Learning
- Gold Price Prediction Using Machine Learning In Python
Options trading is a type of Trading strategy. It is a perfect fit for the style of trading expecting quick results with limited investments for higher returns. You can read all about the options here.
One can create their own Options Trading Strategies, backtest them, and practise them in the markets. Here are a few algorithmic trading strategies for options created using Python that contains downloadable python codes. You can check them out here as well.
To learn the basics of Options Trading, you can check out this article on Basics Of Options Trading Explained.
- Diagonal Spreads
- Calendar Spread
- Synthetic Long Put
- Long Combo
- Bear Spread
- Bear Call Ladder
- Collar Options
- Bull Call Spread
- Butterfly Spread
- Straddle Options
- Jade Lizard
- Iron Butterfly
- Long Strangle
- Iron Condor
- Broken Wing Butterfly
From algorithmic trading strategies to classification of algorithmic trading strategies, paradigms and modelling ideas and options trading strategies, I come to that section of the article where we will tell you how to build a basic algorithmic trading strategy. That is the first question that must have come to your mind, I presume.
The point is that you have already started by knowing the basics of algorithmic trading strategies and paradigms of algorithmic trading strategies while reading this article. Now, that our bandwagon has it’s engine turned on, it is time to press on the accelerator.
And how exactly does one build an algorithmic trading strategy?
We will explain how an algorithmic trading strategy is built, step-by-step. The concise description will give you an idea of the entire process.
1. Decide upon the genre/strategy paradigm
The first step is to decide on the strategy paradigm. It can be Market Making, Arbitrage based, Alpha generating, Hedging or Execution based strategy. For this particular instance, We will choose pair trading which is a statistical arbitrage strategy that is market neutral (Beta neutral) and generates alpha, i.e. makes money irrespective of market movement.
2. Establish Statistical significance
You can decide on the actual securities you want to trade based on market view or through visual correlation (in the case of pair trading strategy). Establish if the strategy is statistically significant for the selected securities. For instance, in the case of pair trading, check for co-integration of the selected pairs.
3. Build a Trading model
Now, code the logic based on which you want to generate buy/sell signals in your strategy. For pair trading check for “mean reversion”; calculate the z-score for the spread of the pair and generate buy/sell signals when you expect it to revert to mean. Decide on the “Stop Loss” and “Profit Taking” conditions.
- Stop Loss – A stop-loss order limits an investor’s loss on a position in a security. It fires an order to square off the existing long or short position to avoid further losses and helps to take emotion out of trading decisions.
- Take Profit – Take-profit orders are used to automatically close out existing positions in order to lock in profits when there is a move in a favourable direction.
4. Quoting or Hitting strategy
It is very important to decide if the strategy will be “quoting” or “hitting”. Execution strategy, to a great extent, decides how aggressive or passive your strategy is going to be.
- Quoting – In pair trading you quote for one security and depending on if that position gets filled or not you send out the order for the other. In this case, the probability of getting a fill is lesser but you save bid-ask on one side.
- Hitting – In this case, you send out simultaneous market orders for both securities. The probability of getting a fill is higher but at the same time slippage is more and you pay bid-ask on both sides.
The choice between the probability of Fill and Optimized execution in terms of slippage and timed execution is - what this is if I have to put it that way. If you choose to quote, then you need to decide what are quoting for, this is how pair trading works.
If you decide to quote for the less liquid security, slippage will be less but the trading volumes will come down liquid securities on the other hand increase the risk of slippage but trading volumes will be high.
Using statistics to check causality is another way of arriving at a decision, i.e. change in which security causes change in the other and which one leads. The causality test will determine the “lead-lag pair"; quote for the leading and cover the lagging security.
5. Backtesting & Optimization
How do you decide if the strategy you chose was good or bad? How do you judge your hypothesis?
This is where backtesting the strategy comes as an essential tool for the estimation of the performance of the designed hypothesis based on historical data.
A strategy can be considered to be good if the backtest results and performance statistics back the hypothesis. Hence, it is important to choose historical data with a sufficient number of data points.
This is to create a sufficient number of sample trades (at least 100+ trades) covering various market scenarios (bullish, bearish etc.). Ensure that you make provision for brokerage and slippage costs as well. This will get you more realistic results but you might still have to make some approximations while backtesting.
For instance, while backtesting quoting strategies it is difficult to figure out when you get a fill. So, the common practice is to assume that the positions get filled with the last traded price.
What kind of tools should you go for, while backtesting?
Since backtesting for algorithmic trading strategies involves a huge amount of data, especially if you are going to use tick by tick data. So, you should go for tools which can handle such a mammoth load of data. Blueshift is a free platform which allows you to perform backtesting, investment research and algorithmic trading, using 10+ years data.
R or MATLAB?
R is excellent for dealing with huge amounts of data and has a high computation power as well. Thus, making it one of the better tools for backtesting. Also, R is open source and free of cost. We can use MATLAB as well but it comes with a licensing cost.
6. Risk and Performance Evaluation
"With great power comes great responsibility"
Fine, I just ripped off Ben Parker’s famous quotation from the Spiderman movie (not the Amazing one). But trust me, it is 100% true. No matter how confident you seem with your strategy or how successful it might turn out previously, you must go down and evaluate each and everything in detail.
There are several parameters that you would need to monitor when analyzing a strategy’s performance and risk. Some important metrics/ratios are mentioned below:
- Total Returns (CAGR) – Compound Annual Growth Rate (CAGR) is the mean annual growth rate of an investment over a specified period of time longer than one year.
- Hit Ratio – Order to trade ratio.
- Average Profit per Trade – Total profit divided by the total number of trades
- Average Loss per Trade – Total loss divided by the total number of trades
- Maximum Drawdown – Maximum loss in any trade
- The Volatility of Returns – Standard deviation of the “returns”
- Sharpe Ratio – Risk-adjusted returns, i.e. excess returns (over risk-free rate) per unit volatility or total risk.
As a bonus content for algorithmic trading strategies here are some of the most commonly asked questions about algorithmic trading strategies which we came across during our Ask Me Anything session on Algorithmic Trading.
Question: I am not an engineering graduate or software engineer or programmer. I don’t know anything about writing a programming language. Then how can I make such strategies for trading? I am retired from the job. Will it be helpful for my trading to take certain methodology or follow? Are there any standard strategies which I can use it for my trading?
Reply: I will break it down into two parts one is that if you don’t have programming experience but you do have some idea about statistics or you do have some idea about trading strategies then the best place to start will be to start learning. You can start connecting with the representatives at QuantInsti® and they can share a lot of material which can help you get started, which is also available on our own portal.
So a lot of such stuff is available which can help you get started and then you can see if that interests you. The good part is that you mentioned that you are retired which means more time at your hand that can be utilized but it is also important to ensure that it is something that actually appeals to you. I do not generally recommend any standard strategies.
There are no standard strategies which will make you a lot of money. Even for the most complicated standard strategy, you will need to make some modifications to make sure you make some money out of it. If it’s standard then it’s standard for a reason which means that it will not be generating any returns. Good idea is to create your own strategy, which is important.
Question: Can we develop MACD divergence using Python?
Reply: Yes, you can. For almost all of the technical indicators based strategies you can.
Question: What are the best numbers for winning ratio you have seen for algorithmic trading?
Reply: The interesting part about algorithmic trading, especially about high frequency trading is that it’s not about the percentage returns that you can generate.
I have seen strategies which used to give 50,000% returns in a month but the thing is that all these strategies, a lot of them are not scalable. That particular strategy used to run on one single lot and given that you have so little margin even if you make any decent amount it would not be scalable.
If I look at it more in perspective of the amount of money it’s making versus the huge amount of infrastructure in place then I cannot make a lot of profit considering it runs on only one.
So looking at the winning ratio would not be the right way of looking at it if it is HFT or if it is low or medium frequency trading strategies typically a sharpe ratio of 1.8 to 2.2 that’s a decent ratio. So again we cannot talk about what the returns are, the returns can be without defining the risk especially if it’s a directional strategy that does not mean much and that’s the reason I gave you the number in Sharpe, if you are scaling it up.
Besides these questions, we have covered a lot many more questions about algorithmic trading strategies in this article.
Check out if your query about algorithmic trading strategies exists over there, or feel free to reach out to us here and we’d be glad to help you.
Some suggested reads for you:
- Learn Algorithmic Trading: A Step-by-Step Guide
- Algorithmic Trading In India: History, Regulations and Future
- Making A Career In Algorithmic Trading
- The Growth And Future Of Algorithmic Trading
- Workshops, Events and Webinars on Algorithmic Trading and HFT
I hope you enjoyed reading about algorithmic trading strategies. You can also learn how to execute a Statistical Arbitrage strategy in our post ‘Statistical Arbitrage: Pair Trading In The Mexican Stock Market‘ that explains a contrarian strategy designed to profit from the mean-reverting behaviour of a certain pair ratio in the Mexican market.
The entire process of Algorithmic trading strategies does not end here. What I have provided in this article is just the foot of an endless Everest. In order to conquer this, you must be equipped with the right knowledge and mentored by the right guide. That’s where QuantInsti comes in, to guide you through this journey.
If you want to know more about algorithmic trading strategies then you can click here.
Disclaimer: All data and information provided in this article are for informational purposes only. QuantInsti®makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information in this article and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis