HI everyone
I am starting with the platform and am unable to understand how and why the number of orders is always really high for me and most of them are due to invalid orders that are there because of 0 price
Am I making an error in the logic . Can someone help me out wrt to this ? I have attached my backtest and with it the code .
Mia Alissi
Hi Tushar,
Invalid orders in backtests can occur due to a variety of reasons. Here are a few possibilities:
Insufficient Capital: If your algorithm tries to place an order that requires more capital than is available in your portfolio, the order will be marked as invalid.
Data Issues: If there's an issue with the data for a particular symbol at a particular time, it could lead to invalid orders. For example, if the price of a symbol is reported as 0, any orders involving that symbol would be invalid.
Order Logic Issues: If there's an issue with the logic in your algorithm that determines when and how to place orders, it could result in invalid orders. For example, if your algorithm is trying to place orders for symbols that aren't currently trading, those orders would be invalid.
Without seeing your specific code, it's hard to say exactly what the issue might be. However, you can debug your algorithm by logging order events and examining the logs to see why orders are being marked as invalid. Here's an example of how you might do this in Python:
This will log any order events that have a status of
Invalid
, and the log message will include information about the order that might help you figure out why it was invalid.Also, consider reviewing the Bootcamp lessons and the Introduction to Financial Python tutorial to get more familiar with the QuantConnect API and how to handle orders.
Sources:
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.
Tushar Verma
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!