Hi,
Wondering if anyone with options experience can help me out here. My goal is to open an iron condor every day on the contract expiring that day. I want to set a stop loss of 300% on the credit received (i.e. if I receive $100, I want to set stop loss at -$300 so my net loss is -$200 if the stop is hit).
Because I am selling options, I feel as though the self.Portfolio.TotalUnrealizedProfit figure is not reflecting correctly? Can someone please confirm if my code is correct for the logic I'm trying to capture above?
Many thanks in advanced.
Louis Szeto
Hi Mcdawgzy
The filled price of an asset's trade might not be the instantenous price of it, especially options featured a lot of HFT market makers in reality. In backtest, it'll also be filled in the next bar only (otherwise we'll have look ahead bias). I'll suggest you save the order ticket and fetch its filled price later, or handle it in the order event handler.
For the stop loss, if you only trade 1 combo at a time, simply add up the UnrealizedProfit field of all portfolio holding objects to see if they dropped below -2 * credit received on every OnData loop. If you hold more than 1 combo, I'll suggest use a dictionary of {[list/set of symbols]: trigger price of stop loss} to check each group using a for-loop.
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.
Mcdawgzy
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!