A Beginner’s Guide to Backtesting
When developing investment strategies that are more sophisticated than ‘hold’ or ‘hire a guy,’ you’re going to need some tools in the box. Backtesting is one of those. It allows traders to play out scenarios in a sandbox, and while there’s no silver bullet when it comes to mitigating risk, it can enable us to make wiser decisions when committing capital.
So with that in mind, let’s first take a look at how backtesting works before going over its strengths and weaknesses, and then a closer look at the context of crypto trading.
A Quick Overview
So, what is backtesting exactly, and how is it done? In short, the idea is to plug a strategy into historical data. There are manual and automated ways to achieve this, the latter of which is not necessarily the best. A simpler algorithm based on historical trends won’t have the insight of a human armed with a spreadsheet to dig into the specifics and pick up on the quirks of the data. On the other hand, modern machine learning is beginning to supersede human cognitive bias, in the same way that Alphago beat the Go world champion after making counterintuitive move #37.
One thing to note about backtesting is that it is by no means a new phenomenon, having been used in markets like stocks and forex for years. The essential components are to make a hypothesis with clear parameters, use it against empirical data, and analyze the results without over-generalizing. FXCM’s guide on forex backtesting drills down further into specifics such as relevant software, defining and optimizing parameters, and discusses how backtesting can be combined with forward testing in an evolving market to create a more comprehensive strategy overall.
Is Backtesting Worth it?
Investopedia points out that accounting for a number of factors, in theory, is a strategy that has worked in the past and should have merit in the present. However, this is also true of poor strategies.
Manual backtesting teaches you to manage emotional responses as the candles are generated, and the strategy is pursued, making apparent its level of clarity.
Improper implementation, often due to simple errors, will yield results that skew an investor’s understanding of a model’s effectiveness. While automation could minimize error, this may have the effect of magnifying confidence in flawed inputs.
Bias is an ever-present danger. Formula Stocks provides a detailed list of the various types of relevant bias and what to do about them.
Backtesting in Crypto Investing
Your mileage may vary when backtesting on the crypto market based upon your skills with programming. If you have skills with languages such as MATLAB, R, or Python with pandas, it’ll be easier to plug in historical data. Python can be used in conjunction with data from some of the popular exchanges we’ve highlighted before such as Binance to fine-tune the model to your heart’s content. Beyond this, however, there are a number of open and proprietary tools ranging from the simple and streamlined to the less intuitive that traders can use to perform backtesting analysis. Even using trusty old Excel against a candlestick chart is still an option here. The basic principles that are true of backtesting in any market are true here. Namely, begin by acquiring high-quality data, usually from a major exchange in this case, and keep testing and refining before using a strategy. It’s also important to include trading fees and slippage in the simulation in order to achieve better accuracy. Finally, crypto is highly volatile and prone to ‘black swan events such as the Terra crash in May 2022, which will make the data very lopsided, so distinguishing between ‘normal’ trends and such events is important.
Backtesting can be an incredibly valuable tool when used properly. As with any market analysis, though, there are many caveats and pitfalls to watch out for, and being aware of these is an important first step to using it successfully.