Hi, testing Long Butterfly on SPY.
- Buy 1 ATM Call
- Buy 1 ATM Put
- Sell 1 OTM Call to decrease cost of Long Call
- Sell 1 OTM Put to decrease cost of Long Put
Overall, it works as expected, but I'm getting a lot of errors like this. Does anybody know why and how to fix it?1181 | 05:18:56: Backtest Handled Error: The security with symbol 'SPY 180202P00266000' is marked as non-tradable.
1182 | 05:18:57: Backtest Handled Error: The security with symbol 'SPY 180202P00261000' is marked as non-tradable.
1183 | 05:18:58: Backtest Handled Error: SPY 180207P00255000: asset price is $0. If using custom data make sure you've set the 'Value' property.
1184 | 05:19:00: Backtest Handled Error: SPY 180209P00253500: asset price is $0. If using custom data make sure you've set the 'Value' property.
1185 | 05:19:00: Your algorithm messaging has been rate limited to prevent browser flooding.
Jing Wu
For OptionChainProvider, you need to wait until the next time step to receive the data after adding the contract with "AddOptionContract()". Therefore, the first time you place the order over the contract which was just added at the same time, there is the error message.
Nicolas Ferrari
Hello Jing Wu, Im having the same issue than Artemiusgreat, what do you recommend to solve this?
Â
Add the option contract earlier related to the signal?
Regards,
Nicolás
Â
Halldor Andersen
Hi all.
This Long Strangle tutorial is a good reference for implementing a Long Butterfly options strategy. Sell instead of buy Out-The-Money (OTM) call and a put option:
### In TradeOptions()
# Sell OTM Call and OTM Put
self.Sell(self.call.Symbol ,1)
self.Sell(self.put.Symbol ,1)
Also, locate ATM put and call options and buy the contracts:
# Put
put = [i for i in chain if i.Right == OptionRight.Put]
putContracts = sorted(sorted(put, key=lambda x: x.Expiry, reverse=False),
key=lambda x: abs(x.UnderlyingLastPrice - x.Strike))
self.atmPut = putContracts[0]
# Call
call = [i for i in chain if i.Right == OptionRight.Call]
callContracts = sorted(sorted(call, key=lambda x: x.Expiry, reverse=False),
key=lambda x: abs(x.UnderlyingLastPrice - x.Strike))
self.atmCall = callContracts[0]
# Buy ATM Call contract and ATM Put contract
self.Buy(self.atmCall.Symbol ,1)
self.Buy(self.atmPut.Symbol ,1)
I've attached a backtest where I demonstrate how to extend the Long Strangle tutorial algorithm to implement a Long Butterfly options strategy using the code snippets above.
Â
Â
Artemiusgreat
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!