Greetings everyone! I am not familiar with back testing options - nor coding for options yet - and would like to know if this is possible.
On the first trading day of the week after the market opens, buy x number of at-the-money call/put options based on the previous weeks' trend. Close position 1) if the option bid price drops X% below or 2) on the last trading day of the week 15 minutes before market close. (Note: I did not use Monday/Friday to account for holidays)
Up-trend example: Monday, October 25th 2021, TQQQ opens at $142.95. The previous weeks open/close was $134.28 and $141.25, respectively. On the 30M chart, the 50 EMA is trending up. After market open, purchase TQQQ weekly Oct 29 $143.00 calls at market price. Sell on the last trading day of the week unless stopped out before then.
The same logic holds for the down-trend example just in reverse.
A few things to consider:
- For back testing purposes, perhaps it would be best to allow the user to choose either the first day of the week or any specific day of the week (i.e. Wednesday).
- I understand there are no ‘Stop Loss' orders with Options, but we should be able to continue checking the option price and, when it reaches a certain level, liquidate.
Thanks!!
Varad Kabade
Hi James Hawkins,
Thank you for your patience. Yes, the above requirements can be implemented with QC; we recommend going through the options tutorial and the following example algorithms - [1, 2].
Best,
Varad Kabade
James Hawkins
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!