Backtesting Best Practices
Understanding settlement for physically-settled securities and how it impacts backtest results.
This article was provided from Option Alpha Community member "Robert DiNero" in this post.
There have been several posts about QQQ expirations as well as the backtester. After spending a considerable amount of time reading I wrote a lengthy comment back in May in response to a post. Since this topic continues to come up, I thought I'd go to the source for clarification. For the most part, this confirmed my understanding of how QQQ settlement works.
Main points
SPY/QQQ/IWM/GLD/TLT settlement time is stamped at 4:00 pm EST.
SPY/QQQ/IWM/GLD/TLT trades until 4:15 pm EST even on expiration day.
A long option holder can exercise their contract until 5:30 pm EST.
If your short options are ITM at 4:00 pm EST they will be auto-assigned.
If your long options are ITM at 4:00 pm EST they will be auto-exercised unless you file a contrary assignment notice.
As the seller of an option contract, you collect the premium upfront to take on the obligation of that contract and keep that premium regardless of the expiration price.
How does this impact risk?
If you hold until expiration, then you have risk of assignment even if it expires OTM (i.e. pin risk: see my comment here). That risk exists regardless of whether options stop trading at 4pm or 4:15pm since long contract holders can exercise options until 5:30. If QQQ were to close OTM but QQQ moves past your short strikes after-hours, then you will not know whether you will be assigned until the next morning leaving you open to unmitigated risk.
If you were assigned on a short call, then you would be short 100 shares for every contract assigned, which in turn means that a $1 move up will reduce your profits by $100 per contract (i.e. 200 contracts with a $3 move up is a -600 loss). That loss can be greater than the max loss defined by the spread since you no longer have the long option contract as protection (unless you call your broker and exercise it, which is a whole other discussion).
Another risk is that your broker closes the position before 4:15pm. They may submit an order that is not in your favor in order to reduce their risk, which could result in a loss greater than the max risk you thought you had. In addition, this would count as a daytrade.
Will Option Alpha know whether I'm assigned or whether my broker sold the position?
OA will not receive data via the API regarding the assignment or the sold position. This means that you could have shares of stock that have been affected by overnight moves. It also means that your account may be assigned positions you either do not have enough buying power for, or aren't approved to hold (i.e. short shares). This in turn means that you could have a margin call and be unable to open positions until the margin call is resolved.
It also means that you will need to edit your closing order in OA to reflect the gain or loss on assignment/sale. Kirk has a video on how to handle assignments in OA. (Kirk has a bolt on early options assignment risk automation that can help with early assignment risk. See also posts here and here).
How does this impact the backtester and results?
In my opinion, it doesn't. No backtester can determine whether a long contract holder will exercise their rights after 4pm. Only a subset of long contract holders will exercise their rights and even then the OCC will randomly assign the contract to a broker, who will randomly assign it to a contract holder.
Then are the closing prices of the backtester wrong for ETFs?
The PL shown in the backtester is correct in the sense that it reflects the price at 4pm, which is when the QQQ settlement time is stamped and when the bots stop running. However, you have a significant risk of assignment that cannot be accounted for in the backtester, which in turn affects your own specific results and how you individually may handle the assignments.
For example, at 4pm the position either expires ITM or OTM. If it closes OTM, then the PL correctly reflects premium received. However, you could still be assigned and end up with a different gain/loss if the underlying price (not the contract price) moves against you. If it closes ITM, then the PL shows what would be the cash settled price. If it closes ITM between the short and long strikes then you would be assigned and you could end up better off or worse off depending on whether QQQ moves in your favor overnight. If it closes ITM beyond your long strike, then you would most likely end up with your max loss at expiration. However, you could still end up buying 100s of shares of QQQ if enough long holders file contrary assignment notices (now I imagine this would be extraordinarily rare, but it is still a risk nonetheless especially if QQQ falls overnight).
It's possible that OA could calculate the gain or loss based off of selling your assigned QQQ position the next day at 9:35am, but that assumes that you must close your position at that time. However, you might close your position at 7am or 8am. Or you might hold the assigned stock. Or you might exercise your longs as Otto notes on this thread. Or maybe you buy the underlying at 7:45pm. As you can see, there are several ways to handle an after-hours move that the backtester and bots cannot account for.
Final thoughts
If you are holding QQQ to expiration (or any physically-settled contract) then you need to know exactly what the risks are. The backtester is an important tool in assessing whether your strategy has any merit, but the backtester cannot account for risk of assignment. You should use the data the backtester provides as a starting point, not an ending point. In other words, once you've run your backtest, review the expired positions to determine whether you'd be assigned.
Or better yet, consider closing physically-settled tickers before expiration and use cash-settled tickers for holding through expiration.
Please let me know if you have questions or if anything I said needs to be clarified or corrected.
Last updated
Was this helpful?