Hello, Im debugging my algo, that buy SPY ETF and SPY option based on the value of VIX. When VIX is higher than 35 the algo look for contracts options on SPY and buy one of them based in the conditions that are specified in self.BuyCall() function.
I'm receiving this error message, in the first time that the algo would buy the option:
Backtest Handled Error: Unable to submit order with id -10 which quantity (0.3) is less than lot size (1).
Someone can help on this? I don't figure out what this message means? The error is between lines 101-106 that is where the logic to buy the call option is.
Regards,
Nicolás
Nicolas Ferrari
I have change the order line to self.Buy(option_contract, 2), and now Im receiving this message:
Backtest Handled Error: SPY 151219C00205000: asset price is $0. If using custom data make sure you've set the 'Value' property.
Halldor Andersen
Hi Nicolas
.Use integer instead of a fraction when specifying the number contracts in Buy(), as you have done. To calculate the number of contracts with a target allocation percentage in mind, use `CalculateOrderQuantity()`:
### In OnData() # Calculate number of contracts (30% of portfolio value) quantity = self.CalculateOrderQuantity(contract.Symbol,0.3) # Buy option contracts self.Buy(contract.Symbol,quantity)
I cloned your algorithm, and I ran a backtest. I did not get any error messages - I suspect that third-party data was temporarily unavailable. I've attached the backtest for your reference.
Nicolas Ferrari
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!