Back

Broker not connected during algorithm initialization

Hi, I am using the Visual Studio IDE to build some local testing.

I am using Interactive Brokers for paper trading. I am facing the following problem:

As far as I understand, first the Algorithm is initialized, then the engine will connect to the broker. however, in the algorithm initialziation, the 'AddEquity` method tries to load historical data from the broker connection. This will throw NotConnected errors, because the SetupHandler will only connect after the Algorithm has been initialized. Therefore, I will end up in the 60second timeout.

Am i missing something conceptual or doing something wrong? Thank you!

Update Backtest








Basically it is the GetLastKnownPrice method fired by the security seeder that tries to connect to the broker api.

0

Looks like adapting the 'BrokerageSetupHandler' works. I have moved the 'connect to brokerage' logic to precede the 'Initializing algorithm' code. All unit tests are fine. Altough my problem might be solved I am unsure whether this will cause other problems. Any ideas?

0

Well, apparently it does generate problems, as the OrderProcesor has not been set when swapping the init order. :(

0

Thank you for reporting Anne, we're aware of this now and will work on a fix ASAP.

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.


Thank you Jared. I am curious how this will be solved. :) keep up the good work

0

Resolved Anne, thank you. https://github.com/QuantConnect/Lean/pull/723

1

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.


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