Over 2 million + professionals use CFI to learn accounting, financial analysis, modeling and more. Unlock the essentials of corporate finance with our free resources and get an exclusive sneak peek at the first module of each course.
Start Free
What is Algorithmic Trading?
Algorithmic trading strategies involve making trading decisions based on pre-set rules that are programmed into a computer. A trader or investor writes code that executes trades on behalf of the trader or investor when certain conditions are met.
Examples of Simple Trading Algorithms
Short 20 lots of GBP/USD if the GBP/USD rises above 1.2012. For every 5 pip rise in GBP/USD, cover the short by 2 lots. For every 5 pip fall in GBP/USD, increase the short position by 1 lot.
Buy 100,000 shares of Apple (AAPL) if the price falls below 200. For every 0.1% increase in price beyond 200, buy 1,000 shares. For every 0.1% decrease in price below 200, sell 1,000 shares.
Example of a Moving Average Trading Algorithm
Moving average trading algorithms are very popular and extremely easy to implement. The algorithm buys a security (e.g., stocks) if its current market price is below its average market price over some period and sells a security if its market price is more than its average market price over some period. Here, we consider a 20-day moving average trading algorithm.
The algorithm buys shares in Apple (AAPL) if the current market price is less than the 20-day moving average and sells Apple shares if the current market price is more than the 20-day moving average. The green arrow indicates a point in time when the algorithm would’ve bought shares, and the red arrow indicates a point in time when this algorithm would’ve sold shares.
Advantages of Algorithmic Trading
1. Minimize market impact
A large trade can potentially change the market price. Such a trade is known as a distortionary trade because it distorts the market price. In order to avoid such a situation, traders usually open large positions that may move the market in steps.
For example, an investor wanting to buy one million shares in Apple might buy the shares in batches of 1,000 shares. The investor might buy 1,000 shares every five minutes for an hour and then evaluate the impact of the trade on the market price of Apple stocks. If the price remains unchanged, the investor will continue with his purchase. Such a strategy allows the investor to buy Apple shares without increasing the price. However, the strategy comes with two main drawbacks:
If the investor needs to pay a fixed fee for every transaction he makes, the strategy might incur significant transaction costs.
The strategy takes a significant amount of time to complete. In this case, if the investor buys 1,000 shares every five minutes, it would take him just over 83 hours (more than three days) to complete the trade.
A trading algorithm can solve the problem by buying shares and instantly checking if the purchase has had any impact on the market price. It can significantly reduce both the number of transactions needed to complete the trade and also the time taken to complete the trade.
2. Ensures rules-based decision-making
Traders and investors often get swayed by sentiment and emotion and disregard their trading strategies. For example, in the lead-up to the 2008 Global Financial Crisis, financial markets showed signs that a crisis was on the horizon. However, a lot of investors ignored the signs because they were caught up in the “bull market frenzy” of the mid-2000s and didn’t think that a crisis was possible. Algorithms solve the problem by ensuring that all trades adhere to a predetermined set of rules.
Disadvantage of Algorithmic Trading
1. Miss out on trades
A trading algorithm may miss out on trades because the latter doesn’t exhibit any of the signs the algorithm’s been programmed to look for. It can be mitigated to a certain extent by simply increasing the number of indicators the algorithm should look for, but such a list can never be complete.
More Resources
To keep learning and developing your knowledge of Algorithmic Trading, we highly recommend the additional resources below:
Take your learning and productivity to the next level with our Premium Templates.
Upgrading to a paid membership gives you access to our extensive collection of plug-and-play Templates designed to power your performance—as well as CFI's full course catalog and accredited Certification Programs.
Gain unlimited access to more than 250 productivity Templates, CFI's full course catalog and accredited Certification Programs, hundreds of resources, expert reviews and support, the chance to work with real-world finance and research tools, and more.