Member-only story

Practical Algorithmic Trading — (2) Backtesting

Chris Kuo/Dr. Dataman
15 min readJul 22, 2023

--

We may have a brilliant trading strategy, but without testing the strategy we are still not sure if it will work. Backtesting is the best sandbox for us to conduct testing, called paper trading. It applies a trading strategy to historical market data to determine how it would have performed in the past. This process is an important skill that quantitative analysts possess and implement frequently.

In this post, I will demonstrate how to use a popular open source libraries called backtesting.py for backtesting. I will also explain the common evaluate metrics. I then demonstrate two trading strategies in backtesting. After reading this post, you will be able to perform backtesting. You will also learn how to optimize your trading rules by different evaluation metrics to evaluate your trading styles. The Jupyter Notebook is available for download via this link.

Why do we need to do backtesting?

Backtesting is a crucial component of trading because it lets you to evaluate the performance of your trading strategies. By simulating trades using historical data, you can measure various performance metrics such as profit and loss, risk-adjusted returns, win rate, maximum drawdown, and other relevant statistics. This evaluation helps you determine whether a strategy has the potential to be profitable and if it aligns with…

--

--

Chris Kuo/Dr. Dataman
Chris Kuo/Dr. Dataman

Responses (1)