Hi
When placing a multi-leg option trade (butterfly, iron condor etc.), how to close the trade and its related positions later when a certain criteria is met, for example, exit @ 30% profit or 7 days before expiration?
Any example Python code? Thanks!
Link Liang
Hi Cloud Trader,
There are many ways to do that based on your strategy. Here is my attempt to exit 7 days before expiry based on our Butterfly Spread tutorial. self.CheckForExpiry() is called when we have invested in some options. We could use self.Liquidate() to close all positions and open orders, and self.Liquidate(symbol) to liquidate for specific symbol.
You could also find another example with profit calculation in this post.
Hope it helps!
CloudTrader
Many thanks Link Liang. How would I exit @ 30% profit ?
Jackson Dude
I am new to this and still writing my first strategy from scratch. Simple Bull Call Spread (BPS).
I open my Long Legs first and wait for the order to fill. Before opening the short legs.
I close my Short Legs first and wait for the order to fill. Before closing the long legs.
This is to ensure I never am naked short Call or Puts.
On Data I check:
1 Day to expiration. Take action if required
2 Check the status and price of each BPS leg. Take step if a leg has a issue occurred.
3 calculate profit strategy close if (open fill prices * -1) + current prices > mini profit
did not know there was a option multi leg trade tutorial. I am likely doing everything the hard way. So take everything I write with a grain of salt hehehe
Thank you will check it out.
Any progress on the multi leg order not supported limitation?
Louis Szeto
Hi Jackson
This feature was already made available earlier this year! Please refer to this reply. Cheers
Best
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.
CloudTrader
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!