I have a covered call strategy that works well. No issues with the code, however, I ran into an issue where a covered call was assigned last night but my algo did not track it correctly. Here's what happened. I had 100 shares of QQQ and a covered call with strike of 363. During the day, when the price went above 363, I bought another 100 of QQQ. At the end of the day QQQ closed above 363 at 363.86. Afterhours the price dipped. Now here is the issue. My algo thinks the price dipped to 362.66 and the buy option exercise was completed at 01:33 to close the option position since the price was below the strike. However, this did NOT happen. Interactive brokers shows that 100 shares were assigned at 22:33. I think the time difference is likely just that I'm in California and its 3 hours to new york. That explains the 01:33 time mark (which I thought was unusual). The issue here is that someone exercised the call at that time and I was assigned and lost those shares at $363.00 at 22:33 but my algo thinks the call expired worthless with the underlying price at $262.66. To make thinks more complicated, my algo then put in a sell on market open order for 100 shares at 04:36. That one I cant figure out as I cant find anywhere in my code that would do something like that. I have no idea why it did that but I think its connected to the issue above. I'm probably going to place a scheduled function 1 minute before open to clear any open orders to prevent that sell on market open order from executing if it happens again and it only has ever happened under this circumstance.
Has anyone else ran into issues with covered calls being assigned but quantconnect not tracking those assignments correctly? How can we avoid or correct this?
Thanks! David
David Eldringhoff
This happened again last night. Same thing. Stock ended up above the call at close of day but after regular hours the price dropped a bit. I held on to the QQQ shares because the price at settlement was below the strike but the algo still thinks I assigned them and sold them even though I didn't. Then the portfolio value is all messed up the next day.
Mia Alissi
Hi David,
It seems like there might be a discrepancy in how your algorithm is handling the assignment of the covered call. In QuantConnect, the
OnAssignmentOrderEvent
method is invoked when an option gets assigned. This method should manage the changes in your portfolio due to the assignment. If this method is not correctly implemented, it could lead to the issues you're experiencing.As for the unexpected sell order, without seeing your code, it's challenging to pinpoint the exact cause. However, it's possible that your algorithm is trying to maintain a certain portfolio composition and is selling shares to achieve that. If the assignment wasn't properly accounted for, your algorithm might think it has more shares than it actually does, leading to the sell order.
Regarding the discrepancy in the price at which the option was exercised, it's crucial to note that options can be exercised at any time before expiration if they are American style options. The decision to exercise an option early is usually based on factors like dividends or interest rates, not just the price of the underlying asset. It's possible that the option was exercised early for reasons other than the price dipping below the strike price.
To avoid these issues in the future, you might want to consider adding some checks to your algorithm to ensure that the portfolio composition is as expected and that all assignments are properly handled. You could also consider using a protective collar strategy, which involves buying a put option along with the covered call to limit potential losses.
Here is an example of how to implement a protective collar strategy in Python:
(Source: Protective Collar)
I hope this helps! Let me know if you have any other questions.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
David Eldringhoff
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!