The Basic Backtesting Workflow

The Basic Backtesting Workflow

The Basic Backtesting Workflow. How to setup and optimize a study based on empirical historical data. Step by step explanation with a real-life example.

Backtesting an iterative Process

The Basic Backtesting Workflow

How to setup and optimize a study based on empirical historical data.

Even though backtesting methods cannot guarantee success in the future, they provide an investor some level of confidence. Without confidence and conviction, it's challenging to follow any strategy consistently. So we are going to examine this process in detail. At eDeltaPro, we divide the workflow into four different steps:

First: Define

The first step involves defining the strategy. We define the strategy by setting the underlying symbols, the expiration, the time range, and, most important, the Options contracts involved. Typical Options setups are, for example:

  • Naked Put
  • Naked Call
  • Strangle
  • Vertical spread
  • Iron Condor

And many others. We will not cover the different strategies that can be tested and the market environments in which they flourish. That is the topic for another article.

Second: Set Entry Conditions

Second, you set the "Entry conditions," for example, the frequency of the trade. That can be every trading day, or once the previous position expires, or every Monday.

Third: Early Exit

Third, you must define any "Early Exit" condition. We refer to an Early Exit as any condition that triggers a position to be closed before expiration. For example, we may set up a profit target. Let's say that you want to close your short trade if you can keep half of the premium received. In this case, the early exit condition would be 50% of the maximum profit. If you receive a premium of $1.20, if the contract's market price reaches $0.60 or less at any time before expiration, that will trigger the backtesting algorithm to close the position and keep the profit. Other typical early exits are Stop Losses. You may want to close your trade 20 days before expiration, irrespective of price. That is also an early exit condition. Beware that multiple early exit conditions can be defined, though only one, whichever happens first, will trigger the trade's closing.

Fourth: Adjust & Optimize

Once you have defined the strategy, the entry and exit conditions, you can run the backtest itself. But the exciting part is that the process does not end here. The results you obtain are just the raw material to better understanding the trade and its historical performance. For example, if you observe large losses, you may want to play with setting stop losses and see if you can improve the results.

Note that the quality of the results is always a trade-off between profits and risk, or volatility. You may want to avoid a strategy that generates a significant return but also has a high level of volatility; in favor of a less rewarding one in terms of gross profit but with lower volatility. Sometimes you may find that constructing the right adjustments and setting the suitable mechanics can lead you to a much better strategy with both lower risk and higher return. Also, bear in mind that results are multidimensional. For example, you may want to prefer the strategy with the highest P&L per day instead of just looking at the total P&L of the trade. You may want to check the total drawdown and incorporate that variable into your analysis. This article explains most of the terms used on the backtests results.

Typically you want to run at least 3 to 5 scenarios. You are making adjustments targeted to correct the deficiencies of the results. Once you have several scenarios, you need to compare them side by side. Let's look at practical, real-life trade.

We run a study on MSFT to illustrate the process.

  • Symbol: MSFT
  • Strategy: Short Put
  • 3 Years
  • 45 Days to Expiration (45 DTE)

  • Run 1: We let all trades open until the expiration
  • Run 2: We set an early exit condition" Exit @ 50% of Maximum Profit. 
  • Run 3: Run 2 but re-open immediately
  • Run4: Run 3 + Add a Stop Loss

The first test generates a total profit of $6,457 and $248 per trade. We are leaving all the trades to expire.

In this second run, we asked the trade to close if we can obtain 50% of the maximum profit at any point before expiration. If a trade is closed in this scenario, we wait for the full 45-day cycle before establishing another position. Note that this scenario's total return is lower, but and this is the exciting part, the profit per day is significantly higher; $13.5 vs. $5.9 when leaving until expiration. The average trade is now just 15 days, vs. the full 45-day cycle. In our view, this is a much better trade. And although you are sacrificing some total return, you are exposed to the market significantly less time. Also reduced is the Standard deviation, a measure of the volatility of the trade. 

So let me repeat it; this is a MUCH better trade than the first one, leaving to expiration.

For the third run, we did a small change. Each time a position is closed because it reached maximum profit, we immediately re-open a new trade instead of waiting for the full 45-Day cycle. We now have a total of 62 trades - instead of just 26 on the two previous runs. Not surprisingly, we obtain the best total return. However, all the risk parameters degrade a bit compared to the last run. 

Finally, we add a stop loss to the backtest. A stop-loss will generally cost you money but will improve the risk parameters. In this case, the Stop-loss is reducing volatility from $367 to $271.

You can click the link "Compare" to obtain this table directly from the software. You now have an excellent side-by-side way of comparing the results for all four scenarios. The final call about which of the four strategies is a better fit for your risk tolerance and financial objective is totally up to you. But in our book, runs 2 and 3 are the clear winners.


- eDeltaPro Options Backtest workflow is a four steps process.

- Adjustments are progressively applied to evaluate the different profit vs. risk profiles of each scenario.

- After running several adjusted backtests, you can choose the mechanics that better match your risk tolerance.

- In our example, exiting at 50% of maximum profit improved the overall performance of this trade.