Back

Algo cannot process call buy option

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  

Update Backtest








0

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.


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.

1


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.

 

1


Update Backtest





0

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.


Loading...

This discussion is closed