Hi Everyone,
Here is the algorithm from my most recent QuantConnect algorithm video tutorial: https://youtu.be/Lq-Ri7YU5fU
To clone it, simply click "Clone Algorithm" on the attached backtest. If you have any questions or comments, don't hesitate to let me know.
Louis
S.G.
if you increase the percentage of portfolio for underlying asset to 2%, the 3 year return more than doubles.
Louis
Thanks for the comment S.G. But note that if you change the value of self.percentage to 2, the allocation towards the underlying is not 2%. Instead it is 200% which would mean that you are using margin to open a leveraged position. This comes with higher risk and fees. I'd recommend keeping self.percentage below 1 (which would be 100%).
George Sanders
Great video and thanks for sharing.
Swap out SPY for UPRO or TQQQ and you get some interesting numbers
Granted some of the Draw Downs are a whee bit harsher but interesting results
Derek Melchin
Hi Louis,
Nice algorithm! Thanks for sharing with the community.
Best,
Derek Melchin
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.
Goldie Yalamanchi
I watched the order data, I couldn't get it to buy any puts though... tried from 2017 to 2020 (Nov) with TQQQ and SPY. Maybe I configured something incorrectly. I will print out some log statements and see what is going on.
Louis
Hi Goldie,
Have you cloned the algorithm above or copied the code while watching the video? If you haven't cloned it, I recommend doing so to see if this fixes the problem.
Goldie Yalamanchi
I hit Clone Algorithm from this thread not the video (i didn't even know about it until later).
Oops, yes I guess after sifting thru the order data maybe I was originally thinking to see the Option symbol more noticeably but I guess those weird long numbers are the option symbols.
2020-04-13 16:00:00SPY 200413P00235000Sell Option ExerciseFill:Â $235.00 USD
-4FilledOption Expired - OTMLouis
Hi Goldie,
I am glad it got sorted out.
Andrej Tihole
Hi Louis,
could you pls add a HMA ( Hull ) as a decision criteria, since is very quick and it could exit position when reverses ( under defined condition - value, ...).
This would made your Strategy much more profitable.
Pls let us know about the code, since I am newbie in Py and QuantConnect too.
Wish you a happy and prosperous New Year 2021,
AndreiÂ
Â
Louis
Hi Andrei,
Thanks for the suggestion. I won't add this indicator to this code for now, but I'll keep it in mind for future projects.
It would be a great exercise for you to try to add such an indicator yourself though.
Happy new year to you as well!
Andrej Tihole
Hi Louis,
thanks for your reply...
Since I am completely new in Py, I would like a suggestion where I can find such video, so that I can make it alone...
Thank you very much again for your great projects... They are awesome..
A very great buildblocks to add pieces together and make a very functional BotÂ
Keep on doing it also in 2021 :)
Andrei
Â
Louis
Hi Andrei,
If you are new to Python and QuantConnect, I'd recommend starting with the basics. Firstly, I'd recommend learning standard Python. If you feel somewhat confident with that, I'd recommend starting the QuantConnect bootcamp.
Without understanding the basics, you won't be able to truly understand more complex algorithms either.
I hope this helps.
Fabmei
Hello Louis,
this is great stuff. The strategy seems to cope very well with and profit from vola spikes, however I feel like extended bear markets (2007 onwards) weigh heavy on performance. I have been trying to come up with an improvement but still busy learning and understanding the basics. Maybe this is something for later this year :)
Best, Fabmei
Carsten
LouisÂ
I think there might be a bug (not in your code) in the way the contracts get treated. The hedging value is higher than the value you pay for the option.(factor 100)
The assumtion is, one option contract for 100 shares of the underlying; looks like thats what the stratey equity curve does.
if you check how much you paid for one contract, its only around 1.6 USD when the underlying cost 251 USD.
Thats way too cheep.
I'm calculation how much I pay for all the options like:
self.Securities[self.contract].Close * number_of_options or
self.Portfolio[self.contract].Price * self.Portfolio[self.contract].Quantity
This is the same as what I see later in the orders.
But if the options start to spike self.Portfolio[self.contract].Price * self.Portfolio[self.contract].Quantity is not enought to offset the loss of the underlying asset. But the strategy curve looks like it was offseted.
Looks like the option chain gives you a price for one option one underlyiong and the stratety curve uses one option equals 100 underlying
Louis
Hello everyone,Â
Note that somehow QuantConnect does not allow you to import the CBOE module anymore. So just comment out the following line and everything should work fine again:
Romuald PISTIS
Hi Louis,
thank you for the code, very interesting. Can you just explain the “self.OTM = 0.01" line code. For example if selfOTM = 0.03, what does this mean concerning the Delta's of the Put option? Does it mean Delta of the Put = -0.03 (very OTM)?
Louis
self.OTM determines the percentage that the put option is out of the money. So a value of 0.03 would mean that the algorithm tries to trade a put option that is OTM by 3%. I hope this answers your question. Otherwise, let me know.
Louis
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!