Hello, I don't know if someone has had the same issue with the one I'm currently having. I managed to write some code and it was working fine initially till I tried to dynamically change all tickers &/ symbols from one part of the code so that it can be changed throughout the code and ended up having a huge mess. Now all the symbols / tickers I add or edit from the code traceback an error
Backtest Handled Error: Unable to compute order quantity of EGO. Reason: The security type must be SecurityType.Crypto or SecurityType.Forex. Returning null.
Unable to submit order with id -10 that has zero quantity. is there anyone who may be able to help with this issue please?
Fred Painchaud
Hi Micah,
Difficult to help without code at all. But each security object has an attribute Type which defines if it is an equity, option, forex, etc. That attribute got set to “null” somewhere in your code so then it's broken. Whatever method you are calling for order quantity of EGO is expecting the attribute to be Crypto or Forex (but it is null so it throws the error).
You need to look into your code and see where that bug dealing with the type could happen.
If you post your code, I guess someone could also help.
Fred
Micah Jesse
Micah Jesse
Sorry for the long code but I just had to send the entire thing because I have no idea where the bug is. I tried looking for it multiple times and I’m getting nowhere.
Cole S
Hi Micah,
I searched for that error in the Lean code and we can see it here. It's happening when there is no currency set, which is why it's saying it must be crypto or forex. The error also says it can't submit order with zero quanity, which I think is the root of the no currency error. I added Debug statements before your MarketOrders and outputted the quantity you were submitting. The very first one is zero. It appears the issue is you are trying to submit orders with zero quantity.
Cole S
Here's the backtest with the Debug statements.
Fred Painchaud
Oh yes indeed Cole. I missed the last line of the error in the OP, which is pretty explicit: Unable to submit order with id -10 that has zero quantity.
Fred
Micah Jesse
Thank you so much for highlighting the bug, I've done some modifications on the entire code where the bugs were and it's now working as intended. Thank so much!!!
Micah Jesse
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!