# Methodology

The ORATS Backtester has 3 main components:

  1. The first component is entries. We specify how each trade is going to be entered using entry parameters. For example, symbols we use, strategy to use, start date, end date, days to expiration, deltas, and various other entry parameters.

  2. The second component is exits. We specify how we are going to exit our option trade. For example, exit at expiration, exit at x amount of hold days, exit at X% of profit or loss, and so on.

  3. The third component is advanced features such as multiple symbols, signals, weightings, option adjustments, hedging, custom signals, custom date filters, custom indicators, and much more.

For more details on parameters, see strategies.

For more information on backtesting including videos, see https://info.orats.com/backtest (opens new window)

# How our Backtester works

  1. The Backtester scans for entry from the start date using all the user input entry parameters.

  2. Once an option trade is found, the Backtester calculates the option returns for each day. If there are hedging or married stock position in the strategy, we calculate that for each day at the time of option returns calculation.

  3. For each day, the Backtester checks for exits using all the user input exit parameters.

  4. If any of the exit parameter is triggered, the Backtester exits the option position.

  5. When an option exits, the Backtester scans for entry again and step 1 is started over again until the end date or the latest available date in our database.

  6. If there are overlay stock component in the strategy, the stock daily returns are added to the option daily returns.

  7. If there are any weightings we calculate the weighted returns last when the backtest statistics are calculated.

  8. Adjustments are handled similar to exits but we use adjustment entry and exit triggers to enter and exit adjustment trades.

# Slippage

Slippage is the extra amount paid or the smaller amount received for an option bought or sold compared to the middle of the options bid-ask. We use a percentage of the options bid-ask spread to represent this amount and the percent slippage is different depending on how many legs there are in the trade.

The slippage formula to buy is: Bid + (Ask - Bid) * slippage%

The slippage formula to sell is: Ask - (Ask - Bid) * slippage%

The following table explains the default method to calculate slippage on entering and exiting a trade:

# of Legs Slippage % bid x ask Buy Trade Price Sell Trade Price
1 .75 1.20 x 1.40 1.35 = 1.20 + (1.40-1.20) * .75 1.25 = 1.40 - (1.40-1.20) * .75
2 .66 5.10 x 5.90 5.628 = 5.10 + (5.90-5.10) * .66 5.372 = 5.90 - (5.90-5.10) * .66
3 .56 4.20 x 5.20 4.76 = 4.20 + (5.20-4.20) * .56 4.64 = 5.20 - (5.20-4.20) * .56
4 .53 8.50 x 10.30 9.454 = 8.50 + (10.30-8.50) * .53 9.346 = 10.30 - (10.30-8.50) * .53

According to the table above: for a 1 leg option trade like buying a call, the default slippage is 75% of the bid ask width; for a 2 leg trade like a put spread vertical the slippage would be 66% of the total bid-ask spreads; for a 3 leg trade like a butterfly, slippage would be56% of the bid-ask width for all legs; and finally a 4 leg iron condor would have a slippage of 53%.

# Commission

We use $1.00 per option contract and $0.01 per share of stock when calculating returns. If the option exits out of the money at expiration with $0 value, we only deduct $1.00 for entry. If the option exits in the money at expiration with value, we will deduct two ways on entry and exit. If the option exits early, we deduct two ways on entry and on exit. Same goes with stock returns.

In the backtest API you can enter your own custom commission.

# Calculating daily returns

We calculate our daily returns using notional returns. The change in daily values of the option is divided by the notional or stock price at entry of the trade.

Best way to explain it is to use an example below:

Let's say we entered a XYZ Long Call at $1.20 on 1/3/2007 with a stock price of $100. On 1/4/2007, our option hit $1.80. Our notional daily return calculation would be: ($1.80-$1.20)/$100 = .006 which is .6% daily return on 1/4/2007. Then on 1/5/2007 our option went down to $0.90. Then our daily notional return would be (.90-1.80) / $100 = -.009 on 1/5/2007.

The formula for daily return = option profit / opening stock price.

If there are any stock components (Hedging, covered calls, married puts, etc.)

we use the formula: (option profit + stock profit) / opening stock price.

# Calculating annual returns

We use average returns instead of compound returns since compounding returns create special problems in option trading. To calculate the annual returns for each year, just add up the daily returns for the date range of the year. So if you want to calculate 2007 annual returns, just add up the daily returns from 1/1/2007 to 12/31/2007.

To calculate the total annual returns from all the years, simply add all the daily returns then divided by how many years there are. So for example, let’s say the total return is 32% and the backtest date range is from 1/3/2007 to 10/31/2018. Then you divide 32 from (11 yrs + (10/12)) = 11.83 years. Our backtest annual return would be 32/11.83 = 2.7%.

# Graphing an equity line

To create the equity line from our daily returns, you would multiply the daily returns with a set invested dollar amount you choose for each day.

Formula for the equity line would be portfolio balance + set dollar invested * daily return.

Here's an example table below:

Date Daily Return Portfolio Balance Calculation
1/17/2008 0 $100,000 starting balance
1/18/2008 -0.000207114 $99,979.28 $100,000 + -0.00020711 * 100,000
1/22/2008 -0.00712766 $99,266.52 $99,979.28 + -0.00712766 * 100,000
1/23/2008 0.020309478 $101,297.47 $99,266.52 + 0.020309478 * 100,000
1/24/2008 0.003143133 $101,611.78 $101,297.47 + 0.003143133 * 100,000
1/25/2008 -0.013781431 $100,233.64 $101,611.78 + -0.013781431 * 100,000
1/28/2008 0.000241779 $100,257.82 $100,233.64 + 0.000241779 * 100,000
1/29/2008 0.003868472 $100,644.67 $100,257.82 + 0.003868472 * 100,000
1/31/2008 -0.004226306 $100,222.04 $100,644.67 + -0.004226306 * 100,000