Backtesting (2024)

Applying a strategy or predictive model to historical data to determine its accuracy

Over 1.8 million professionals use CFI to learn accounting, financial analysis, modeling and more. Start with a free account to explore 20+ always-free courses and hundreds of finance templates and cheat sheets.

What is Backtesting?

Backtesting involves applying a strategy or predictive model to historical data to determine its accuracy. It can be used to test and compare the viability of trading strategies so traders can employ and tweak successful strategies.

Backtesting (1)

Summary

  • Backtesting involves applying a strategy or predictive model to historical data to determine its accuracy.
  • It allows traders to test trading strategies without the need to risk capital.
  • Common backtesting measures include net profit/loss, return, risk-adjusted return, market exposure, and volatility.

How Backtesting Works

Analysts use backtesting as a way to test and compare various trading techniques without risking money. The theory is that if their strategy performed poorly in the past, it is unlikely to perform well in the future (and vice versa). The two main components looked at during testing are the overall profitability and the risk level taken.

However, a backtest will look at the performance of a strategy relative to many different factors. A successful backtest will show traders a strategy that’s proven to show positive results historically. While the market never moves the same, backtesting relies on the assumption that stocks move in similar patterns as they did historically.

Backtesting (2)

Implementation

A backtest is usually coded by a programmerrunning a simulation on the trading strategy. The simulation is run using historical data from stocks, bonds, and other financial instruments. The person facilitating the backtest will assess the returns on the model across several different datasets.

It is also essential that the model is tested across many different market conditions to assess performance objectively. Variables within the model are then tweaked for optimization against several different backtesting measures.

Common Backtesting Measures

  • Net Profit/Loss
  • Return: The total return of the portfolio over a given time frame
  • Risk-Adjusted Return: The return of the portfolio adjusted for a level of risk
  • Market Exposure: the degree of exposure to different segments of the market
  • Volatility: The dispersion of returns on the portfolio

Backtesting Bias

When creating a trading model to be backtested, traders must avoid bias in creating the model. In order to ensure objectivity, the strategy must be tested on several different time periods with an unbiased and representative sample of stocks.

If a trader were to pick and choose the stocks and time period in which their strategy is backtested against, the model would be fundamentally flawed. While the test may yield positive results, this would only be because the model was created to fit this data perfectly. Therefore, it is essential that different datasets are used throughout the process.

Look-Ahead Bias

Another mistake when backtesting is look-ahead bias. Look-ahead bias involves incorporating information into the model being backtested that normally wouldn’t be available when the model is actually implemented.

For example, assume you’re backtesting a trading model that relies on financial information available at fiscal year-end. In the model, you enter the information as of December 31st; however, the information generally isn’t available until a couple of weeks after the end of the year. Implementing the data in a backtest would cause the return on the model to be artificially high due to look-ahead bias.

Backtesting (3)

  • A – Fiscal year-end (time at which backtesting model assumes annual report released)
  • B – Annual report released
  • C – Time at which the backtesting model assumes first-quarter report release
  • D – First quarter report released

The graph above shows a timeline of how a backtesting model could become flawed due to look-ahead bias. The model assumes that information becomes available at points A and C, while in reality, the information becomes available at points B and D. The result of a properly constructed backtest would likely yield an entirely different result than the one that makes the same assumptions as above.

Who Uses Backtesting?

Anyone can perform their own backtest; however, backtests are usually run by institutional investors and money managers. Backtesting uses data that can be expensive to obtain and requires complex modeling.

Institutional traders and investment companies possess the human and financial capital necessary to employ backtesting models in their trading strategies. Additionally, with large amounts of money on the line, institutional investors are often required to backtest to assess risk.

Example

Suppose you’re an analyst at an investment firm, and you’ve been asked to backtest a strategy against a set of historical data given to you. The strategy involves buying a stock if it hits a 90-day low. The first step in backtesting would be choosing unbiased historical data.

You then apply the strategy to the data and find that the strategy yielded a return of 150 basis points better than the current strategy used by the company. The backtest helped to solidify the research performed in creating the trading strategy. The investment firm can decide whether the backtest is reason enough to employ the strategy.

Related Readings

Thank you for reading CFI’s guide to Backtesting. To keep advancing your career, the additional resources below will be useful:

Backtesting (2024)

FAQs

Backtesting? ›

Backtesting involves applying a strategy or predictive model to historical data to determine its accuracy. It allows traders to test trading strategies without the need to risk capital. Common backtesting measures include net profit/loss, return, risk-adjusted return, market exposure, and volatility.

What is the meaning of backtesting? ›

What Is Backtesting? Backtesting is the general method for seeing how well a strategy or model would have done after the fact. It assesses the viability of a trading strategy by discovering how it would play out using historical data.

What is an example of a backtest strategy? ›

Example of Backtesting

An investor uses a 50-day moving average as a trading strategy for a stock, and starts to collect price data going back to 2018 as a way to determine whether the stock can match similar returns in the future.

Is backtest one word or two? ›

(intransitive) To test a strategy, model etc. using data from a previous time.

Does backtesting really work? ›

This is that a profitable backtest does not prove that a strategy “worked”, even in the past. This is because most backtests do not achieve any kind of “statistical significance”. As everyone knows, it's trivial to tailor a strategy that works beautifully on any given piece of historical data.

What are the risks of backtesting? ›

Risks and Limitations of Backtesting
  • Data snooping bias: Backtesting involves testing multiple strategies on historical data, which can lead to data snooping bias. ...
  • Overfitting: Backtesting allows traders to optimize their strategies based on historical data.

How much backtesting should I do? ›

When you are backtesting a strategy on a higher timeframe, you will have to go back 6 to 12 months. Ideally, you want to end up with 30 to 50 trades in your backtest to get a meaningful sample size. Anything below 30 trades does not have enough explanatory power.

How do I learn backtest in Excel? ›

We need to get some data for the symbol that we are going to back test.
  1. Go to: Yahoo Finance.
  2. In the Enter Symbol(s) field enter: IBM and click GO.
  3. Under Quotes on the left hand side click Historical Prices and enter the date ranges you want. ...
  4. Scroll down to the bottom of the page and click Download To Spreadsheet.

How to get data for backtesting? ›

One of the best sources of historical data for backtesting is market data provided by reputable financial data providers. These providers collect and store extensive historical data for various financial instruments, including stocks, currencies, and commodities.

What is the best platform to backtest trading? ›

Top best backtesting software for stocks 2024
  1. Amibroker. Amibroker is a comprehensive and highly customizable backtesting platform that allows traders to develop, test, and optimize their trading strategies. ...
  2. TradeStation. ...
  3. MetaTrader 4/5. ...
  4. NinjaTrader. ...
  5. Backtrader. ...
  6. Quant Rocket. ...
  7. Trade Ideas. ...
  8. MultiCharts.
Apr 24, 2024

How do you backtest a strategy without coding? ›

How To Backtest With No-Code. Capitalise. ai's backtesting feature simplifies the process by providing an intuitive, code-free environment. Users can set up their trading rules and parameters through an easy-to-use interface, enabling them to analyze the performance of their strategies over historical market data.

Why is backtesting important? ›

Why is backtesting important? It's important because it allows traders to assess the potential profitability and viability of a trading strategy before implementing it in real-time trading. It helps identify flaws, refine strategies, and make informed decisions based on historical performance.

What is the best way to backtest? ›

The simplest backtest includes looking at one-minute or five-minute chart timeframes, for example, of the asset being traded. You could find prior trades based on that strategy and then add up the profits and losses, which would provide an idea of the profit produced that week.

What is another word for backtesting? ›

In oceanography and meteorology, backtesting is also known as hindcasting: a hindcast is a way of testing a mathematical model; researchers enter known or closely estimated inputs for past events into the model to see how well the output matches the known results.

What is the opposite of backtesting? ›

Quantified Strategies

Backtesting is testing a strategy using historical data to see how it would have performed in the past. Forward testing is applying a strategy to current data to see how it performs in real time. Both are important, but forward testing is crucial for understanding real-time market behavior.

What are the different types of backtests? ›

Common types of backtesting for trading include: In-sample versus out-of-sample testing. Walk-forward analysis or walk-forward optimization. Instrument-level analysis versus portfolio-level assessment.

References

Top Articles
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 5856

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.