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. Once you have decided on the market segment you would want to invest in, you would try to find some information about them, for which we move to the next segment of this article.

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 a 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. We will go through the various platforms in detail later in this article.

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. Let’s discuss them now.

Typical Backtesting Parameters to Evaluate a Trading System

Total P/L

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 P/L

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

The success ratio is the number of 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 is working and how much we need to update or optimise it in order to reap maximum benefits.

Maximum Drawdown

Maximum Drawdown can be 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 the amount of risk we are willing to take.

Sharpe Ratio

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.

Choice of Programming Language

It plays an important role while developing a backtesting platform. Different languages have different pros and cons which when weighed carefully as per needs can boost the system’s performance to a great extent. We’ve briefly discussed some of the most commonly used languages below:

C++

For ultimate execution speed, it offers the most flexibility for managing memory and optimising execution speed but can lead to subtle bugs and is difficult to learn.

C# and Java

Perform automatic Garbage Collection which leads to performance overhead but more rapid development. Both are good choices for developing a backtester as they have native GUI capabilities, numerical analysis libraries and offer fast execution speed.

MATLAB and R

MATLAB is a commercial IDE with multiple numerical libraries for scientific computation. It boasts high execution speed but is still less appealing to retails trades as it is quite expensive. R is a dedicated statistics scripting environment which is free, open-source, cross-platform and contains a wealth of freely-available statistical packages for carrying out extremely advanced analysis but lacks execution speed unless operations are vectorized.

Python

Python is another free open-source and cross-platform language which has a rich library for almost every task imaginable and a specialized research environment. Execution speed is more than sufficient for intraday traders trading on the time scale of minutes and above.