Introduction to Algorithmic Trading
Financial institutions have been rapidly increasing the usage of digital technology since the 1970s. Competitive market enforced having the latest technology in many operations that used to be manual in the past. Looks like one of those would be trading on the markets, where good old ‘gut-feeling’ is becoming less and less useful and leaves a place to clusters of CPUs or GPUs, ‘Big Data’ and so-called ‘Algorithmic Trading’.
What is Algorithmic Trading?
Algorithmic trading means the use of electronic platforms for entering trading orders with an algorithm which executes pre-programmed trading instructions whose variables may include timing, price or quantity of the order. Trades are executed with marginal or without any human intervention, algorithms require investors to first specify their goals in terms of mathematical variables.
The overall trend observed during the past few decades has been towards quantitative ans algorithmic approach in investing and there’s seems to be no reversal from that on the horizon. Algorithmic trading plays a major role in the financial markets and there is good chance it will play even bigger in the future.
Depending on investors needs, customized algorithms range from simple to highly sophisticated, computers implement trades following the exactly prescribed instructions. Algorithmic trading has become possible due to fully electronic infrastructure in stock trading systems. The term black box trading is used to describe very advanced systems operating without or with minimal human intervention.
Pros and Cons of Algorithmic Trading
Algorithmic trading has several advantages compared to trading carried out by a human trader. Computer systems have a much shorter reaction time and reach a higher level of reliability. The decisions made by a computer system rely on the underlying strategy with a specified set of rules, which lead to a reproducibility of these decisions. Consequently, back-testing and improving the strategy by varying the rules possible. Algorithmic trading also ensures objectivity in trading decisions and is not exposed to subjective influences. When trading many different securities at the same time, one computer system may substitute many human traders. Observation and the trading of securities of a large variety become possible for companies without employing hundreds of traders.
Nevertheless, the automated trading requires monitoring, altogether it results in a better performance of the investment strategy as well as in lower trading costs.
It is challenging to automate the whole process from investment decision to execution, there is always a trade-off between system stability and robustness and complexity. The less complex the system the more solid operation, on the other hand, lack of complexity may lead to lower profitability.
Algorithmic trading has been often related to increasing volatility on the markets, according to some algorithms may produce snowball effects and so-called ‘flash crashes’. Another aspect in a discussion about algorithmic trading is its effect on liquidity. These trading strategies may improve liquidity if they act as market makers, but on the other hand, if they create extra imbalance the effect may just the opposite. There are scientific findings that indicate, algorithmic trading improves liquidity and enhances the informativeness of quotes. It helps reducing transaction costs and risk, improves entry speed, increases trade control and reduces bid/ask spread.
Automated Trading System
The concept of an automated trading system refers to an idea of computer trading program that automatically submits trades to a given exchange. Depending on a trading frequency the speed of data may have a significant influence whether the trading system is profitable or not. An automated trading system consists of many layers all of which must be taken into consideration. First of all, trading system must have a reliable market data feed. This data is being fed to algorithms to find if there are currently such market conditions, which would have been likely profitable trading opportunities according to back-test (Alpha Model). If the back-test support market conditions then the risk management should be taken into account: does this trade fit to our current portfolio’s risk profile and what kind of effect it has on portfolio’s total market exposure (Risk Model). Assuming the potential trade ticks two above boxes, it can be executed on the market. Before executing an order, a strategy should also tell when the trade should be exited if the market turns against the trade but also when to close the profitable trade (Transaction Cost Model).
The result of a strategy will be the returns over time of those trades and the performance measures. Just to scratch the surface, there are two main kinds of strategies to perform in quantitative trading, mean-reversion and momentum. If the price of an asset is relative low or high respect a reference, for example, the average historical price of a share, and it is expected the come back to that reference, the strategies exploiting this situation are called mean-reversion strategies. For example, it is possible to make a strategy with two stocks highly correlated in time. If the prices are moving in opposite direction (making the difference between them greater) buying one and selling the other with the same amount of money expecting a reverse in that movement. Momentum strategies follow a trend in a certain direction.
Pitfalls to avoid
In the strategy research process, there are numerous ways to fall in pitfalls, leading in well-performed strategies with historical data but useless with real-time prices.
The main issues may be:
- Taking into consideration stocks splits and dividends
- Missing data and abnormally differences between periods
- Survivorship bias, problem testing only companies that are ‘alive’
- Use data that it has not been generated during the period analyzed
- Overfitting, use parameters to fit the historical data
- Overfitting, use parameters to fit the historical data
To begin with, the data sources could contain errors. The dividends are discounted in the stock price, the past data is usually adjusted to not have big drops in prices when, actually, the money is in the account of the investor. Also, the prices have to be adjusted when the company decides to divide a share into multiples shares, the same way the prices have to do. The reliability of the data has associated a data cost to pay to the provider and must to discount to the final result of the strategy. An important associated cost and typical pitfall to fall not including it in the strategy result is the transaction cost. This is the price paid to the broker to send the orders to the market. For this reason, the strategies with fewer trades and great returns in each trade are good to avoid this cost. The pitfall called survivorship bias is when that is not including in the strategy research the companies that went into bankruptcy. Another important pitfall is overfitting, strategy performs well only with historical data used for tuning, but underperforms in live conditions. To avoid this bias, the strategy has to be tested with additional data or “out-of-the-sample” data before going life. Last but not least, look-ahead bias, that is using data that were not available in the test period, for example, a financial ratio that is brought at the end of the year.
Traders use a variety of ratios to measure and compare the performance of different strategies. This process is present in the whole cycle of testing and tuning to ensure the performance will be good at a time when strategy executes real trades.
Most often the media or investment fund reports show the returns to tell how an investment had performed, it says little of the characteristics and risk of the investment.
Things like long periods of negative returns or high returns followed by big drops are not always expected by investors, to take that into consideration few measures have been developed:
Sharpe Ratio – it measures the excess return of the portfolio (above the risk-free rate) in terms of excess portfolio’s volatility. The ratio measures just the alpha component of the total return. Important to note that the Sharpe Ratio does not distinguish between positive and negative returns at the volatility.
Sortino Ratio – it is a modification of the Sharpe Ratio where only the downside volatility penalizes the ratio.
Drawdown measures like ‘max drawdown’ that is the maximum percentage decrease in capital encountered in the period or ‘max drawdown period’ that is maximum period in which strategy was losing money
Understanding the concept of risk is crucial for creating a good risk management strategy. Risk can be defined as the uncertainty of outcomes. In the financial literature, a risk is the likelihood of losses resulting from unexpected events related to movements in the market. Extreme events (like crashes) may have a low probability of occurring but also may cause a big loss. These low probability events are more intractable because they are usually hard to anticipate. Algorithmic trading is exposed to different types of risk which could be generally categorized into two main types: market risk (related to market behavior) and operational risk (eg. infrastructure failure).
As financial markets become more competitive, financial institutions and private investors have started to turn to automated trading, to gain competitive advantage. With the ability to communicate electronically with exchanges and other electronic trading venues, it is now possible to construct automated trading systems to analyze the changing market data and place orders when certain criteria are met. These systems can be customized to execute almost any trading strategy. Different people might utilize algorithmic trading systems to achieve different objectives although most of them contain one of the basic layers:
- The trading signal generation
- Risk management
- Systems that automate the trade execution
Was the above useful? Please share with others on social media.
Recommended reading list:
|Applied Quantitative Methods for Trading and Investment
This much-needed book, from a selection of top international experts, fills a gap by providing a manual of applied quantitative financial analysis. It focuses on advanced empirical methods for modelling financial markets in the context of practical financial applications.
Data, software and techniques specifically aligned to trading and investment will enable the reader to implement and interpret quantitative methodologies covering various models.
The unusually wide-ranging methodologies include not only the 'traditional' financial econometrics but also technical analysis systems and many nonparametric tools from the fields of data mining and artificial intelligence. However, for those readers wishing to skip the more theoretical developments, the practical application of even the most advanced techniques is made as accessible as possible.
The book will be read by quantitative analysts and traders, fund managers, risk managers; graduate students in finance and MBA courses.
|Quantitative Technical Analysis: An integrated approach to trading system development and trading management
This book, the fifth by Dr. Howard Bandy, discusses an integrated approach to trading system development and trading management.
It begins with a discussion and quantification of the several aspects of risk.
1. The trader's personal tolerance for risk.
2. The risk inherent in the price fluctuations of the issue to be traded.
3. The risk added by the trading system rules.
4. The trade-by-trade risk experienced during trading.
An original objective function, called "CAR25," based on risk-normalized profit potential is developed and explained. CAR25 is as near a universal objective function as I have found.
The importance of recognizing the non-stationary characteristics of financial data, and techniques for handling it, are discussed.
There is a general discussion of trading system development, including design, testing, backtesting, optimization, and walk forward analysis. That is followed by two parallel development paths -- one using traditional trading system development platform and the second machine learning.
Recognizing the importance of position sizing in managing trading, an original technique based on empirical Bayesian analysis, called "dynamic position sizing" and quantified in a metric called "safe-f," is introduced. Computer code implementing dynamic position sizing is included in the book.
56 fully disclosed, ready-to-run, and downloadable programs are included.
|Finding Alphas: A Quantitative Approach to Building Trading Strategies
Design more successful trading systems with this practical guide to identifying alphas
Finding Alphas seeks to teach you how to do one thing and do it well: design alphas. Written by experienced practitioners from WorldQuant, including its founder and CEO Igor Tulchinsky, this book provides detailed insight into the alchemic art of generating trading signals, and gives you access to the tools you need to practice and explore. Equally applicable across regions, this practical guide provides you with methods for uncovering the hidden signals in your data. A collection of essays provides diverse viewpoints to show the similarities, as well as unique approaches, to alpha design, covering a wide variety of topics, ranging from abstract theory to concrete technical aspects. You'll learn the dos and don'ts of information research, fundamental analysis, statistical arbitrage, alpha diversity, and more, and then delve into more advanced areas and more complex designs. The companion website, www.worldquantchallenge.com, features alpha examples with formulas and explanations. Further, this book also provides practical guidance for using WorldQuant's online simulation tool WebSim® to get hands-on practice in alpha design.
Alpha is an algorithm which trades financial securities. This book shows you the ins and outs of alpha design, with key insight from experienced practitioners.
Learn the seven habits of highly effective quants
Understand the key technical aspects of alpha design
Use WebSim® to experiment and create more successful alphas
Finding Alphas is the detailed, informative guide you need to start designing robust, successful alphas.
|Inside the Black Box: A Simple Guide to Quantitative and High Frequency Trading
New edition of book that demystifies quant and algo trading
In this updated edition of his bestselling book, Rishi K Narang offers in a straightforward, nontechnical style—supplemented by real-world examples and informative anecdotes—a reliable resource takes you on a detailed tour through the black box. He skillfully sheds light upon the work that quants do, lifting the veil of mystery around quantitative trading and allowing anyone interested in doing so to understand quants and their strategies. This new edition includes information on High Frequency Trading.
Offers an update on the bestselling book for explaining in non-mathematical terms what quant and algo trading are and how they work
Provides key information for investors to evaluate the best hedge fund investments
Explains how quant strategies fit into a portfolio, why they are valuable, and how to evaluate a quant manager
This new edition of Inside the Black Box explains quant investing without the jargon and goes a long way toward educating investment professionals.
|Automated Trading with R: Quantitative Research and Platform Development
Learn to trade algorithmically with your existing brokerage, from data management, to strategy optimization, to order execution, using free and publicly available data. Connect to your brokerage’s API, and the source code is plug-and-play.
Automated Trading with R explains automated trading, starting with its mathematics and moving to its computation and execution. You will gain a unique insight into the mechanics and computational considerations taken in building a back-tester, strategy optimizer, and fully functional trading platform.
The platform built in this book can serve as a complete replacement for commercially available platforms used by retail traders and small funds. Software components are strictly decoupled and easily scalable, providing opportunity to substitute any data source, trading algorithm, or brokerage. This book will:
Provide a flexible alternative to common strategy automation frameworks, like Tradestation, Metatrader, and CQG, to small funds and retail traders
Offer an understanding of the internal mechanisms of an automated trading system
Standardize discussion and notation of real-world strategy optimization problems
What You Will Learn
Understand machine-learning criteria for statistical validity in the context of time-series
Optimize strategies, generate real-time trading decisions, and minimize computation time while programming an automated strategy in R and using its package library
Best simulate strategy performance in its specific use case to derive accurate performance estimates
Understand critical real-world variables pertaining to portfolio management and performance assessment, including latency, drawdowns, varying trade size, portfolio growth, and penalization of unused capital
Who This Book Is For
Traders/practitioners at the retail or small fund level with at least an undergraduate background in finance or computer science; graduate level finance or data science students
|Quantitative Momentum: A Practitioner's Guide to Building a Momentum-Based Stock Selection System (Wiley Finance)
The individual investor's comprehensive guide to momentum investing
Quantitative Momentum brings momentum investing out of Wall Street and into the hands of individual investors. In his last book, Quantitative Value, author Wes Gray brought systematic value strategy from the hedge funds to the masses; in this book, he does the same for momentum investing, the system that has been shown to beat the market and regularly enriches the coffers of Wall Street's most sophisticated investors. First, you'll learn what momentum investing is not: it's not 'growth' investing, nor is it an esoteric academic concept. You may have seen it used for asset allocation, but this book details the ways in which momentum stands on its own as a stock selection strategy, and gives you the expert insight you need to make it work for you. You'll dig into its behavioral psychology roots, and discover the key tactics that are bringing both institutional and individual investors flocking into the momentum fold.
Systematic investment strategies always seem to look good on paper, but many fall down in practice. Momentum investing is one of the few systematic strategies with legs, withstanding the test of time and the rigor of academic investigation. This book provides invaluable guidance on constructing your own momentum strategy from the ground up.
Learn what momentum is and is not
Discover how momentum can beat the market
Take momentum beyond asset allocation into stock selection
Access the tools that ease DIY implementation
The large Wall Street hedge funds tend to portray themselves as the sophisticated elite, but momentum investing allows you to 'borrow' one of their top strategies to enrich your own portfolio. Quantitative Momentum is the individual investor's guide to boosting market success with a robust momentum strategy.
|Quantitative Trading: How to Build Your Own Algorithmic Trading Business
While institutional traders continue to implement quantitative (or algorithmic) trading, many independent traders have wondered if they can still challenge powerful industry professionals at their own game? The answer is "yes," and in Quantitative Trading, Dr. Ernest Chan, a respected independent trader and consultant, will show you how. Whether you're an independent "retail" trader looking to start your own quantitative trading business or an individual who aspires to work as a quantitative trader at a major financial institution, this practical guide contains the information you need to succeed.
|Algorithmic Trading and DMA: An introduction to direct access trading strategies
Algorithmic trading and Direct Market Access (DMA) are important tools helping both buy and sell-side traders to achieve best execution (Note: the focus is on institutional sized orders, not those of individuals/retail traders).
This book starts from the ground up to provide detailed explanations of both these techniques:
An introduction to the different types of execution is followed by a review of market microstructure theory. Throughout the book examples from empirical studies bridge the gap between the theory and practice of trading.
Orders are the fundamental building blocks for any strategy. Market, limit, stop, hidden, iceberg, peg, routed and immediate-or-cancel orders are all described with illustrated examples.
Trading algorithms are explained and compared using charts to show potential trading patterns. TWAP, VWAP, Percent of Volume, Minimal Impact, Implementation Shortfall, Adaptive Shortfall, Market On Close and Pairs trading algorithms are all covered, together with common variations.
Transaction costs can have a significant effect on investment returns. An in-depth example shows how these may be broken down into constituents such as market impact, timing risk, spread and opportunity cost and other fees.
Coverage includes all the major asset classes, from equities to fixed income, foreign exchange and derivatives. Detailed overviews for each of the world's major markets are provided in the appendices.
Order placement and execution tactics are covered in more detail, as well as potential enhancements (such as short-term forecasts), for those interested in the specifics of implementing these strategies.
Cutting edge applications such as portfolio and multi-asset trading are also considered, as are handling news and data mining/artificial intelligence.
|Python for Finance: Analyze Big Financial Data
The financial industry has adopted Python at a tremendous rate recently, with some of the largest investment banks and hedge funds using it to build core trading and risk management systems. This hands-on guide helps both developers and quantitative analysts get started with Python, and guides you through the most important aspects of using Python for quantitative finance.
Using practical examples through the book, author Yves Hilpisch also shows you how to develop a full-fledged framework for Monte Carlo simulation-based derivatives and risk analytics, based on a large, realistic case study. Much of the book uses interactive IPython Notebooks, with topics that include:
Fundamentals: Python data structures, NumPy array handling, time series analysis with pandas, visualization with matplotlib, high performance I/O operations with PyTables, date/time information handling, and selected best practices
Financial topics: mathematical techniques with NumPy, SciPy and SymPy such as regression and optimization; stochastics for Monte Carlo simulation, Value-at-Risk, and Credit-Value-at-Risk calculations; statistics for normality tests, mean-variance portfolio optimization, principal component analysis (PCA), and Bayesian regression
Special topics: performance Python for financial algorithms, such as vectorization and parallelization, integrating Python with Excel, and building financial applications based on Web technologies
|A Guide to Creating A Successful Algorithmic Trading Strategy (Wiley Trading)
Turn insight into profit with guru guidance toward successful algorithmic trading
A Guide to Creating a Successful Algorithmic Trading Strategy provides the latest strategies from an industry guru to show you how to build your own system from the ground up. If you're looking to develop a successful career in algorithmic trading, this book has you covered from idea to execution as you learn to develop a trader's insight and turn it into profitable strategy. You'll discover your trading personality and use it as a jumping-off point to create the ideal algo system that works the way you work, so you can achieve your goals faster. Coverage includes learning to recognize opportunities and identify a sound premise, and detailed discussion on seasonal patterns, interest rate-based trends, volatility, weekly and monthly patterns, the 3-day cycle, and much more—with an emphasis on trading as the best teacher. By actually making trades, you concentrate your attention on the market, absorb the effects on your money, and quickly resolve problems that impact profits.
Algorithmic trading began as a "ridiculous" concept in the 1970s, then became an "unfair advantage" as it evolved into the lynchpin of a successful trading strategy. This book gives you the background you need to effectively reap the benefits of this important trading method.
Navigate confusing markets
Find the right trades and make them
Build a successful algo trading system
Turn insights into profitable strategies
Algorithmic trading strategies are everywhere, but they're not all equally valuable. It's far too easy to fall for something that worked brilliantly in the past, but with little hope of working in the future. A Guide to Creating a Successful Algorithmic Trading Strategy shows you how to choose the best, leave the rest, and make more money from your trades.