Backtesting a trading strategy is the process of testing a trading hypothesis/strategy on prior time periods. Instead of applying a strategy for the time period forward (to judge performance), which could take years, a trader can simulate his or her trading strategy on relevant past data.
For example, say, a trader wants to test a strategy based on the notion that Internet IPOs outperform the overall market. If you were to test this strategy during the dotcom boom years in the late 90s, the strategy would outperform the market significantly. However, trying the same strategy after the bubble burst would result in dismal returns. The maxim ‘past performance does not necessarily guarantee future returns’ has to be kept into consideration while backtesting a trading strategy.
Automated Backtesting and Manual BacktestingJust like we have, manual trading and automated trading, backtesting, too, runs on similar lines. Simply speaking, automated backtesting works on a code which is developed by the user where the trades are automatically placed according to his strategy whereas manual backtesting requires one to study the charts and conditions manually and place the trades according to the rules set by him. If one is good at coding, then automated trading would be of great benefit. However, one needs to keep in mind the current market conditions and tune his strategy and code accordingly to fit these conditions or it may give inaccurate results due to the changing market conditions.
Key Decisions for Backtesting Trading Strategy
Choose the right market/asset segment
Taking into consideration various factors such as the risks you are willing to take, the profits you are looking to earn, the time for which you will be investing, whether long-term or short-term, you can make a decision as to which market or assets will be best for the kind of trading you are looking to conduct. Some options such as trading in cryptocurrencies might be riskier than others but can give higher returns and vice versa. Hence, it is a crucial decision to select the right market and asset class to trade in.
Data to cover the variety of market conditions
The prices in a market are vulnerable to many factors and hence keep fluctuating depending on the kind of situation going on. These factors may include major announcements like monetary policies, the release of the annual report of a company, inflation rates, etc. The key point to consider here is the fact that the market will not always behave in a similar way and this is the reason why we need to test the trading strategies on various market conditions so that we know how the strategy will perform in those conditions.
Platform to code and backtest trading strategy
There are platforms available which provide the functionality to perform backtesting on historical data. The important points to consider before selecting a backtesting platform are knowing which asset classes does the platform support, knowing about the sources of the market data feeds it supports and figuring out which programming languages and be used to code the trading strategy which is to be tested.
Evaluate the system on benchmark parameters
We perform backtesting to understand how a trading strategy will work on future data by measuring its performance on the historical data. And we gauge its performance based on certain parameters such as dollar P/L, success ratio, Sharpe ratio etc. We will discuss these parameters further in this blog.
Process of BacktestingAfter finalizing the decisions mentioned above, we can move ahead and create a trading strategy to be tested on historical data. For Backtesting, we can use various methods available including using platforms and simulators to test their strategy.
One can also build a model using Excel VBA and test it later with Python or R(if needed). Apart from this, testing on a simulator can give insight into the problems faced during the execution of a strategy. Simulator behaves like an exchange which can be configured for various market conditions. For simulator testing, the implementation of the testing system would require additional knowledge for Python/C++/java.
Once the strategy and data are in place and the backtesting is performed, we can begin the analysis of the result using various parameters to develop and upgrade the trading strategy.
Platforms Used for BacktestingApart from Excel VB, a quick backtesting of trading strategy for certain kind of strategies (for mainly technical trading) can be done using special platforms such as AmiBroker, Tradestation and Ninja Trader.
TradeStation provides electronic order execution across multiple asset classes. It allows trading from charts and live P&L portfolio management. TradeStation uses ‘EasyLanguage’ to create charts and develop algorithmic trading strategies. This language, as the name suggests, is easy to learn as it is very similar to English and hence be great for someone who is a beginner in coding.
NinjaTrader, a free software, uses the very widely used and exquisitely documented C# programming language and the DotNet Framework. It can be used for stock, futures and forex markets for advanced charting, strategy backtesting and trade simulation.
Quantra Blueshift is a free and comprehensive trading and strategy development platform and enables backtesting too. It helps one to focus more on strategy development rather than coding and provides integrated high-quality minute-level data. Its cloud-based backtesting engine enables one to develop, test and analyse trading strategies in a Python programming environment.
Amibroker is a trading analysis software which allows portfolio backtesting and optimization, and has a good range of technical indicators to analyse the strategy. It uses ‘AmiBroker Formula Language (AFL)’ to develop and implement trading strategies and indicators.Apart from these, there are more platforms like Quantopian, MetaTrader, etc. and you can read about them here.
Typical Backtesting Parameters to Evaluate a Trading System
Total Profit or Loss will help us determine whether the trading strategy actually benefited us or not. We can understand how much overall profit or loss can be incurred through this strategy in similar scenarios as the historical data it was tested on.
Average profit or loss will denote the amount of profit or loss which we can incur in one unit of time (days, minutes, hours) over a specific time period.
Success ratio is the number trades we won or profited from to the number of trades we lost or incurred a loss on. This is an important indicator to understand how well our trading strategy in working and how much we need to update or optimise it in order to reap maximum benefits.
Maximum Drawdown can used as a measurement of risk. It denotes the maximum fall in the value of the asset from a peak value. This helps us assess the risk involved and the amount of loss that we could incur from our trading strategy, thus helping us decide amount of risk we are willing to take.
Two strategies may give us equal returns, in this case, the strategy with a lower risk will be considered better than the other. The measure of this is called the risk-adjusted return and can be calculated using the Sharpe Ratio.Backtesting proves to be one of the biggest advantages of Algorithmic Trading due to the fact that it allows us to test our strategies before actually implementing them in the live market. In this blog, we have covered the basic topics one needs to know before starting backtesting. You can learn to develop and implement more than 15 trading strategies in the course below. 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.
Suggested Read: Top Backtesting Platforms for Quantitative Trading