16 Jul Learn Algorithmic Trading
To understand what algorithmic trading is, first we need to understand the concept of an algorithm. Simply put, an algorithm includes a certain set of defined instructions with the goal of carrying out a process or task. Today algorithms are widely used across various industries, including healthcare, retail, financial services, transport, and many others.
The use of algorithms in trading progressed after computerized trading systems were introduced in American financial markets during the 1970s. Algorithmic trading (also called automated trading, algo trading or quant trading) is the process of utilizing computers that are programmed to follow a defined set of directions for placing a trade to generate profits at a frequency and speed which is impossible for human traders. The defined sets of regulations are based upon price, quantity, timing, or any mathematical model. Aside from profit opportunities for a trader, algo-trading will make markets more liquid as well as make trading more systematic by ruling out any emotional human impacts upon trading tasks.
Algo trading can be part machine trading alongside human intervention, or it can be fully automated trading software – which requires only to be switched on and takes all trades autonomously.
Any strategy an individual daytrader may have can be coded into a series of hard rules:
E.g. something absurd like selling stocks in May and buy back in October. This is a rule and can be coded as such. In this simple example we could effectively create an algorithmic trading strategy with the following code:
(Using the SPY index) If marketposition = 1 and month = May (so if we are long SPY and month is May) Then sell next bar at market (we sell our complete position at the next bar at market price) If marketposition = 0 and month = October Then buy next bar at market
This is a very simple example of an algorithm. As you can see it is nothing but a series of programmed rules encoded into software that understands the rules, then applies to rules to various markets the user has chosen. All you need is trading automated trading software, coding expertise, live data feed and a compatible broker API.
One of the major advantages of algorithmic trading is that it automates the trading process, so trades are placed instantly and traders can be sure that they don’t miss out any opportunities. By the time regular trader would click mouse button, algo trading systems can potentially enter and exit a trade. Manual orders can’t come close to mimicking the speed of algorithmic trading. Additionally, trading without human intervention avoids costly errors often caused by traders and their emotions. Eliminating trading psychology of fear and greed, orders are placed based on a winning backtested strategy which has all the risk pre-defined.
Algo trading systems are also capable to complete simultaneous checks upon hundreds of market conditions within a few milliseconds (depending on your platform and hardware infrastructure). Algo systems can also trade multiple market strategies simultaneously without making any errors, this is a major advantage for those trading a large portfolio or pairs and arbitrage traders. Without a trading bot, it would be unimaginable to trade even several markets at the same time.
Algorithmic trading also improves or at the very least reduces transaction costs due to faster orders and better trade fill, thus allowing investors to potentially increase profits.
3. The downside to algorithmic trading
The major disadvantage of algorithmic trading is that with one mistake traders can rapidly lose their money. The faulty algorithm can trigger hundreds of transactions within a few seconds and if something goes wrong, the investor’s capital can be lost in that same time frame. There has been many high profile banks with traders who have encountered either an algo that goes haywire or the typical human fat finger mistake.
An algorithmic trading platform needs operational hardware during the execution of trades. Dedicated computers, servers and connections are needed to ensure the system runs correctly. Some platforms do not operate entirely via internet connections and data servers, and instead, store impending trade orders on the client-side computer. In the event of a lost connection, that trade may not occur.
Although the use of technology helps to eliminate human errors, algorithmic trading systems require to be constantly monitored due to the risk of errors, glitches, and power losses. Nasdaq recommends that traders set up monitoring and surveillance teams that work 24/7. However, monitoring systems 24/7 is beyond what the majority of traders and small firms are looking for. The average retail trader thinking of trading whilst they sleep please recognise that automated trading is not unattended trading, what can go wrong will go wrong.
Automated trading systems need constant optimising and many times cannot compete with a strong human trader who is able to adapt to changing market conditions. Automated trading systems working purely of technical analysis will not be able to process news announcements and fundamental information which can easily move markets. Automated trading has also created illegal markets where algo traders spoof orders, this was highlighted to the public when the high profile case of ‘The Hound of Hounslow” who was arrested and used as the scapegoat for the flash crash in 2010.
Algo trading has been blamed for poor market price action which has lead to buying and selling based on no real underlying value expectations of stocks or the economy. If algo bots see momentum they all fire orders creating many artificial market environments with no fundamental basis, this leads to erratic stocks and market prices leading to very fast crashes.
4. How does algorithmic trading work?
Algorithmic trading bot identifies market inefficiencies and exploits them, potentially resulting in substantial profits. All algo trading strategies follow a set of defined rules, suppose a trader follows the below trade criteria:
- Purchase 50 shares of a stock as its 50-day moving average rises beyond the 200-day moving average
- Sell stock shares as its 50-day moving average dips under the 200-day moving average
These two simple instructions can be written to automatically monitor stock price (and the moving average indicators) and place the buy and sell orders when the defined conditions are met. This simple algorithm is much more efficient than a trader who would monitor the live prices and graphs, or place orders himself.
However, in practice trading algorithms are much more complex and require a lot of knowledge and research. We do not recommend starting live trading without testing your strategy and performing various analysis. Quant Savvy offers 100% hands-free futures trading system to increase returns and minimise potential risk. Our automated trading systems invest autonomously, eliminating the psychology of investor from trading decisions.
Finding Inefficiencies in the Market
An inefficient market is one in which an asset’s prices do not accurately reflect its true value. Most market display some level of inefficiencies. Quant Trading experts expose those inefficiencies in the market using sophisticated computerized algorithms that can generate returns for investors. Market inefficiencies exist due to information asymmetries, transaction costs, market psychology, and human emotion, among other reasons. Many believe in efficient market hypothesis, while others exploit deviations. However, efficient market hypothesis is mainly academic and does not apply to live trading to generate real profits.
In an inefficient market, some investors can make excess returns while others might lose more than expected. Quant trading experts say: “If you can’t measure risk, then you can’t manage risk”. Most of the human discretionary fund’s trade based on pure guesswork. All markets tend to trend beyond random, so there is no right or wrong method, as long as exposed market inefficiencies show some repeatable behaviour – read more about quantifying market inefficiency. However, there is an important ‘Black Swan’ phenomenon to consider. Even though algorithmic trading is not affected by human emotions, there are multiple market dips, or black swans, with algo trading. There is a sudden dramatic move in the market before it returns to normalcy shortly afterwards.
Finding a Fundamental Truth to each Market
All-day trading automated trading strategies are based on finding a fundamental truth about the market. Quants aim to define rules which seek best to model repeatable non-random behaviour. Some Quants might use technical analysis and test if repeatable patterns exist in past market data, some may use arbitrage models and others may use order flow analysis. Whatever method is used the Quant will break down the premise into a series of basic rules and test them on various sets of market data. If the tested rules prove to show an edge well beyond random then the rules can be pursued further, and a system can be designed around these core set of rules:
- Algo trading strategies can collect data on order flow and model behaviour of other algorithms, once a participant tips one’s hand your algo trading strategy can take advantage and expose and inefficiency time and time again.
- Investors love trend/momentum following but have to wait for months to profit. Moreover, long term trades can be pure luck whereas Quant tends to work on a day trading timeframe and can make even 100s of trades a day. On a day trading level, the same market trends exist, your algo trading strategy determines when is the best probability of catching a strong trend.
5. Algorithmic Trading Strategies
Creating your algo trading strategies you can keep to the KISS rules (keep it simple stupid) or go for complexity. What I find is that begin every strategy with a simple concept, something you may have observed the market doing. If you spot a repeatable pattern simply try to code the logic and test it on a very basic level. If you are curious to learn more, read our article: Finding a Trading Edge.
The following was cribbed from Hedge Trade blog – read their blog post to learn more about each strategy
Trends-following aims to take advantage of long, medium, and short term movement in the market. This strategy does not try to predict a new trend, it simply bets on the maintenance of a current trend. The simplest way to identify a trend is by following the moving average. Once moving average changes, traders determine when is the best time to buy or sell.
Arbitrage is when an investor buys a stock in a lower price market and then sells it on another market with a higher value. An investor can employ arbitrage by buying a stock on a foreign exchange where the price has not yet increased to another market’s rate.
High-frequency trading (HFT) often employ arbitrage strategies. The strategies include different forms of arbitrage – index arbitrage, volatility arbitrage, statistical arbitrage and merger arbitrage along with global macro, long/short equity, passive market making, and so on. HFT relies on the ultra-fast speed of computer software, data access (NASDAQ TotalView-ITCH, NYSE OpenBook, etc) to important resources and connectivity with minimal latency (delay).
Rebalancing strategy involves analyzing the investment holding within the portfolio and adjusting to the original allocation at the desired frequency to maintain a specific level of risks. When rebalancing takes place, there is an opportunity for algo traders to capitalize on these exchanges that offer 20 to 80 basis points profits.
Trading Range or Mean Reversion
Algorithms are used to make purchases when an asset’s price moves out of its defined range. This defined range is the ‘trading range’. It is also a ‘mean revision’ because it acts on the temporary price of an asset. That means that algorithms are looking for real averages and aims to exclude the outliers.
Breakout, mean reversion, and trend following are three main themes the market can be in. If you can spot the current market theme you can apply an algorithm that exploits the market behaviour (the hard part is spotting the current theme).
Volume-weighted Average Price
Volume and price determine the average price of a security traded throughout the day. Volume traded average offers insight into the trend and value of a security. Passive investors often use the volume-weighted average price as a benchmark, which can include mutual funds and pensions.
Time-weighted average Price
This strategy aims to move discrete chunks of an asset at specific time intervals without causing the price of an asset to drop or rise dramatically. The idea is to maintain the average price when the order is being executed. If a large amount of stock is released to the market, traders and trading systems are alerted about a major change. The big movement in the market might be negatively interpreted and stocks’ prices can be dramatically affected.
Examples of algorithmic trading strategies can also use the following logic:
– Some daytraders feel that markets/stocks are fractal and there is some evidence to suggest this. Markets tend to work in waves/fractals or have other repeatable patterns. Daytraders that adhere to this style of trading often follow patterns such as head and shoulder, triangles, rectangles, wedges, etc.
– Your basic moving averages, RSI, etc. (what we find is that most indicators are completely useless and lag the market. Moving averages can be used as a complementary filter to an otherwise decent algorithmic trading strategy, however.
– Most daytraders know that most of their money will come from periods of high volatility; this is because on a day trading level this is when markets are at their most inefficient. Algo trading can perform superbly during these periods because they adhere to strict rules and do not suffer from fear and greed.
– Comprising of numerous features, from patterns to indicators.
– Can be categorized as technical analysis. Can be useful but very hard to code the logic of support and resistance into a quant trading system
– The pairs trade is market-neutral, meaning the direction of the overall market does not affect its win or loss.The goal is to match two trading vehicles that are highly correlated, trading one long and the other short when the pair’s price ratio diverges “x” number of standard deviations – “x” is optimized using historical data. If the pair reverts to its mean trend, a profit is made on one or both of the positions.
Backtesting is the key ingredient to the success of an algorithmic trading strategy and trading bot. One of the best algorithmic trading advantages is that investors can backtest their trading strategy based on historical and real-time data.
If you are interested in trying algorithmic trading for yourself it is important that you have advanced computer knowledge before setting up this type of trading strategy. If you don’t have any experience in trading or programming you should strongly consider leaving this algo trading to an expert with advanced knowledge.
7. Learn Algorithmic Trading
The most difficult aspect of learning to become an Algo trader is where to start. Algorithmic trading requires knowledge in several fields: quantitative analysis/modelling, programming skills, trading/financial markets knowledge. The easiest way to begin any new pursuit is with the help and guidance of a mentor. Those who don’t have this option, often trust the help of books and the internet to find a starting point. However, you should consider that various resources might have misleading information, so we highly recommend to trust experts or find a mentor.
Now the biggest caveat when it comes to finding books to learn algorithmic trading is that you are not going to be given automated strategies (not any that will work anyway) – these you must work to find on your own. What you can be given is outline how to begin the process of coding, software to use, correct backtesting methodology, and best metrics for evaluation of your quant trading strategy.
“First and foremost you need to learn how to code.”
This is probably the most daunting aspect for most daytraders or even ex floor traders. However, let me assure you that learning to code algorithmic trading strategies can be very simple and easy and most will pick it up within a couple of weeks of learning.
Modern trading software has made it very easy for us to code, something like Multicharts is geared with simple coding language and most technical functions are pre-built into the software. For the average quant, you do not require anything more than top of the line retail software. Quant Savvy has compared different software and trading platforms to identify its pros and cons.
There is no need to re-invent the wheel and start creating your own software (this takes too much time and effort and advanced computing and coding skills). Why take on the arduous task of creating your own software when there are companies out there working on this for you each and every day. Obviously, for very complex trading strategies a custom-built platform and software are required but I would say 9 out 10 daytraders needs are fully met by retail software.
To begin with, I would simply recommend learning to code quant trading strategies in something simple like Multicharts using their own basic programming language (learn more). We have also prepared a list of learning resources, including books and blogs, for you to have where to start.
Books to find ideas from:
Let me start out by saying most books on algorithmic trading are useless to the average trader, some are needlessly mathematically complex and others are simply flawed and basic. The only books I found of any use were ones where the backtesting process was rigorously discussed. Books where correct data mining practices and how not to overfit data or curve fit have been useful. Moreover, books wish to give you tools to evaluate your algorithmic trading strategy potential success and measure your edge have also proved to be useful.
Do not expect to find the holy grail of day trading strategies in a book. A good book can set you on the right track but getting to the finish line will be based on your quantitative reasoning, logic and ability to find an edge. See article: Finding a Trading Edge.
Books which give you a good story about algorithmic trading or day trading in general also can be a fun read as well are:
- When Genius Failed, by Lowenstein: popular recantation of the LTCM fiasco
- Market Wizards: Interviews with Top Traders (Books) Jack Schwager
- This Time is Different: Eight Centuries of Financial Folly (Books) – Carmen M. Reinhart
Other books which you might find algo trading strategy ideas – you can code up the rules and test them out (bear in mind doing this might be good practice but also be aware that hardly any of systems in the books work when tested rigorously; some work for certain periods of time and then fail under different market conditions):
- Studies in Tape Reading (Books) Richard D. Wyckoff
- Steidlmayer on Markets: Trading with Market Profile – J. Peter Steidlmayer
- Dynamic Trading: Dynamic Concepts in Time, Price and Pattern Analysis with Practical Strategies for Traders and Investors (Books) Miner, Robert C
- Technical Analysis of Stock Trends (Books) Magee, John
Advanced Quantitative books including complex mathematics and understanding behind quant trading:
- Advanced Trading Rules (Quantitative Finance) (Books) Acar, Emmanual
- Applied Quantitative Methods for Trading and Investment (The Wiley Finance Series) (Books) Dunis, Christian
Very important books on correct procedure on backtesting algo trading strategies:
- Evidence-Based Technical Analysis: Applying the Scientific Method and Statistical Inference to Trading Signals – David Aronson
The resources on the internet are numerous when it comes to quant trading. In addition to algorithmic trading books, beginners have access to:
8. Technical Requirements
At the bare minimum for algorithmic training you need to have:
- A computer program that can read current prices, feeds, with order placing capability, backtesting capability
- Access to trading platforms to place orders
- Access to historical data
- Startup money to invest
9. Get Started
Code it Yourself
I would advise nearly all daytraders or individuals thinking about day trading to at least attempt to code some of their strategies. I think a lot of daytraders will say they can beat the returns of any algo trading system, hence they don’t want or need to learn quant trading. I feel this is often because ultimately they are scared that their strategy does not show any edge and usually they end up trading on gut feeling (gambling). If you are serious about trading and investing then nearly any strategy can be coded and automated.
Computing power is such a huge advantage it would be silly not to use it. Not only can you test 100s of strategies, but when a quant trading strategy has been fully automated it can run live on numerous markets leaving you with free time to test and try out new strategies.
Trust quant trading experts
If you do not have the required knowledge and don’t want to risk your money with a weak strategy, we recommend hiring algorithmic trading professionals. Therefore, maintaining a server is also a major aspect to consider if you decide to trade by yourself.
Quant Savvy offers algorithmic trading systems for retail and professional investors since 2014. We maintain and monitor all servers 24/7 and pay their maintenance fee. Therefore, our users are free to be involved in trading as much or as little as they want. See our results here.