LEARN BACKTESTING IN 3 MINUTES – BLOCKCHAIN 101

Abstract

Backtesting is a way to optimize the trading behavior and process of traders, such as whether the trading ideas and strategies are reasonable and whether they can bring profits.

 

So, what is backtesting? How to conduct backtesting? What are the precautions? We will answer all these questions in this article.

 

Guide reading

“Backtesting”, the full name of historical backtesting, is a method to provide valuable feedback based on historical data to test the profitability and risk attributes of a strategy.

Its working principle is to feed the historical market data of the whole market for a certain period of time to the tested strategy, and let it run automatically in a simulated trading environment, and finally evaluate the strategy according to the transaction records of the strategy.

Historical backtesting is a great killer of quantitative investment.

 

 

Before introducing “historical backtesting”, let’s discuss what is the essence of quantitative strategy.

The essence of quantitative strategy is a complete set of algorithm rules, including how to choose coins, when to buy, when to sell, how to stop losses, how to manage positions and so on.

We write this set of algorithm rules of the strategy into code, compile it into a program, deploy it to the computer for execution, and then feed in the current position and real-time market data, and the strategy will start to run automatically and adjust positions in real time.

At this time, how can we have a whim and feed the historical market data to the quantitative strategy in chronological order?

The quantitative strategy will still be calculated according to the historical market data fed to it, and the instructions for position adjustment will be given in chronological order, just like going back to the past through time and space.

This is the basic principle of “historical backtesting”. Knowing this, we will come back to discuss what is historical backtesting.

 

What is backtesting?

The core principle of backtesting, simply put, is to construct a simulated trading environment (backtesting environment) with real historical market data and let the strategy run in it. Like time travel, the strategy goes back to a certain time node in history and starts running again.

Then, according to the transaction records of the strategy output, the profitability, risk control ability and other related indicators of the strategy are evaluated.

In other words, it uses past data to observe the implementation of the strategy. If the backtesting results are good, traders or investors can start to apply this strategy to practical operations.

 

How to conduct backtesting? (Case Source Network)

The demands of trading strategy:

  • Our closing price in the first week was higher than 20 weeks.Moving averageWhen buying bitcoin,
  • And sell bitcoin when the first closing price is lower than the 20-week moving average.

This strategy only produces a few signals every year. Let’s take a look at the time period from 2019.

 

Weekly chart of Bitcoin since 2019

 

This strategy produces five signals in the measuring time range:

  • Buy at a price of about $4,000
  • Sell for about $8,000.
  • Sold for about $8,500.
  • Sell for about $8,000.
  • Buy @ ~$9,000

 

The backtesting results show that the strategy should be profitable at that time. Does this mean that it will certainly work in the future? Can’t. This only shows that looking back at this specific data set, the strategy should be profitable at that time. This result can only be used as a rough benchmark.

Please note that we only looked at the data within two years. If you want to turn it into an executable scheme, you need to go back to an earlier time period and test it with more price behaviors.

Having said that, this is a good start. As long as the initial idea is tenable, we can establish an investment strategy from it through further optimization. Maybe you can add more parameters and.Technical indicatorsMake the signal more reliable. It all depends on one’s idea, investment period and risk tolerance.

 

Efficiency brought by historical backtracking test

The biggest advantage of historical backtracking test is its high efficiency, which directly spans the examination time of trading strategy verification. For example, we need to verify the feasibility of a trading strategy, which is as short as three months and as long as one or two years. The consumption of these time makes the execution efficiency of trading strategy infinitely lower.

It is much more convenient if you use “historical backtracking”. To test the performance of the strategy in a certain three months, it is only necessary to feed the historical market of this period to the strategy. If you are not at ease, you can even feed it to the strategy through the performance of the past three years and five years for verification.

Historical backtracking has also brought great convenience to the developers of strategies. Developers can quickly verify the effectiveness of the strategy through historical backtracking, optimize the strategy algorithm according to the backtracking results, then verify and re-optimize, and carry out iterative optimization, which greatly speeds up the development and optimization of the strategy. Moreover, developers can also specify the time period of historical backtracking and do targeted algorithm optimization.

 

Problems of historical retrospective testing

Historical backtesting greatly improves the efficiency of strategy development and optimization, but it also brings two problems. One is the future function, and the other is over-fitting, both of which will lead to the failure of the strategy in different degrees in the real environment.

  • The future function is to bring back the information that happened later when traveling through time and space.
  • Over-fitting means that the details of trading strategy are adjusted and optimized too much.

We will elaborate on these two concepts in subsequent courses.

 

Summary

Historical backtesting is an essential model for all quantitative traders, but it should be noted that it may not be possible to establish a feasible trading strategy by backtesting alone, and more technical analysis indicators are needed. However, it is undeniable that historical backtesting is of great benefit to testing trading ideas and grasping market pulse.

 

Related Articles

Responses