When I go live with interactive brokers (all backtests work without issue) I get the following error:
“During the algorithm initialization, the following exception has occurred: Error getting open orders from brokerage: Object reference not set to an instance of an object.Object reference not set to an instance of an object. in BrokerageTransactionHandler.cs:line 1303 Object reference not set to an instance of an object.”
Although I'm not 100% sure this is the cause, the error has only started happening since I <manually> opened a short position via the IB interface, leading me to believe there is some janky interplay between QC and IB syncing in cases where there are manually opened trades. Does anyone have any experience with this? Indeed, before I had to restart the algorithm, the opening of the short position caused my reported equity in the QC live view to increase according to the value of the position, which makes some logical sense but is obviously not ideal/typical/expected behaviour.The easiest way for me to confirm that this position is what is causing the problem is to close the short position manually and try again, but this has drawbacks for obvious reasons.
Any advice much appreciated,
All the best,
M
Mia Alissi
Based on the information provided in the extracts, it seems like the error "Object reference not set to an instance of an object" typically occurs when you're trying to access a property or method on an object that hasn't been initialized yet.
In your case, it seems like the error is occurring when the algorithm is trying to get open orders from the brokerage. This could potentially be due to the manually opened short position via the Interactive Brokers interface.
However, without more specific information about your code and the exact circumstances under which the error occurs, it's hard to provide a definitive solution.
One of the users in the forum discussions suggested initializing properties in the
__init__
method of your class to avoid this error. Here's how you can do it in Python:Now, when you try to access these properties in your algorithm, they will have been initialized and you shouldn't get the "object reference not set up" error.
If the issue persists, it would be best to submit a support request to QuantConnect with the algorithm attached for more assistance.
Please note that this advice is based on the information available in the extracts and might not completely solve your issue.
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.
Matthew Vowels
The problem occurs even with the most basic QCalgorithm without any trading logic. As soon as qc attempts to sync with the brokerage the error occurs. Again, this has only happened since I ‘manually’ opened a short position via the IB interface, and I had to redeploy.
Mia Alissi
Based on the information provided in the extracts, it seems like the error "Object reference not set to an instance of an object" typically occurs when you're trying to access a property or method on an object that hasn't been initialized yet.
In your case, it seems like the error is occurring when QuantConnect attempts to sync with the brokerage. This could potentially be due to the manually opened short position via the Interactive Brokers interface.
However, without more specific information about your code and the exact circumstances under which the error occurs, it's hard to provide a definitive solution.
If the issue persists, it would be best to submit a support request to QuantConnect with the algorithm attached for more assistance.
Please note that this advice is based on the information available in the extracts and might not completely solve your issue.
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.
Swiftmox
I got the same error as well. Just tried and still having the issue even for an algo that doesn't do anything.
My positions are not manual trades so it probably doesn't matter.
The lean version is showing “master v16027 2023-11-17 20:13” and I wanted to test with earlier version of lean but the drop down doesn't show other version selection. Searching for ways to go to earlier lean, short of setting up local.
Matthew Vowels
Indeed I tried the same thing with a very simple algo and got the same issue.
Made me wonder if there was some problem with symbols not lining up between IB and QC.
Thankfully I only have one position open and I don't stand much to lose by closing it. Will post again as soon as I can test the deployment with the position closed.
Matthew Vowels
I can confirm that closing the position on IB enabled me to ‘go live’ successfully with the algorithm.
Thus the issue does indeed seem to be synchronisation of IB with QC. If anyone has any details about how to handle this, it would be appreciated, as this is quite a serious issue that currently prevents me (and I imagine, others like Swiftmox) from relaunching the algo when there are open positions.
Martin Molinero
Hello Matthew Vowels
Thank you for the report, and sorry for the inconvenience. We've identified the issue and disabled the bugged version.
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.
Matthew Vowels
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!