I have come across this issue several times and I am stumped on how to avoid this. In the log you will see that on 06 March 2020 the program attempts to purchase an option contract with the symbol AAPL XCZJLDKSQ82U|AAPL R735QTJ8XC9X which is actually the symbol ID. Of course this error causes the backtest to either return an error or time out after 10min. This has happened at various times during the trading day and with many adjustments to the parameters and even different indicators and resolutions. It seems to be unavoidable.
I have tried using the symbol.Contains method, also checking if the contract is tradable, etc but this seems to not make a difference. Any help will be greatly appreciated!
Shile Wen
Hi Benjamin,
The issue is that CalculateOrderQuantity sometimes returns 0 if there is little cash left, which then causes a market order for 0 shares. We need to make sure this value is greater than 0 before investing. I've shown this fix in the attached backtest.
Best,
Shile Wen
Benjamin Sanchez
Shile Wen,
How can that be true when there are zero holdings, a start cash of 100K, and total equity of 103K? I cloned your backtest and ran it with a start date of 2020, 8, 1 and end date of 2021, 4, 1 and still encountered the same issue described above. For some reason the backtest isn't showing up when I try to attach it so I am including images.
If you run the program with those dates you will see that on 2020-10-02 the algorithm is trying to purchase a contract with the symbol AAPL XIQBGZLYPFC6|AAPL R735QTJ8XC9X. The log shows that the alogorithm is incorectly using the symbol ID rather than the symbol value. Ensuring that the quantity is above zero does not mitigate this. This issue still causes the backtest to time out.
My question is why is the algorithm using the symbol ID and how to prevent it?
Derek Melchin
Hi Benjamin,
We are working to resolve this issue. For the time being, we can retrieve the symbol in string format with
contract.Symbol.Value
See the attached backtest for reference.
Best,
Derek Melchin
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.
Benjamin Sanchez
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!