3

Is it possible to run an IB (Interactive Brokers) Gateway as a Windows service? I would like to operate a 7/24 solution without the need to log on the OS.

Pavel
  • 362
  • 4
  • 13
  • I don't think it's possible directly through the IB API. In order to use any of the API's, you must log in to TWS and supply your credentials. A lower resource option is to use the Gateway, but both options include the auto log off feature, that logs you off every night (not sure what time). You could write a program that automatically logs you in every morning, but you still have to suppty your credentials (ID, PW and security code card). Check out this: http://twsstart.free.fr/ – Fred Quatro Mar 15 '17 at 16:25
  • IB Gateway _doesn't_ log off automatically therefore a good candidate for continuous running - the setup that I have. After some research I found this project [ib-controller](https://github.com/ib-controller/ib-controller) but without further investigating. – Pavel Mar 15 '17 at 21:59
  • Pavel, please note that you can, at IB remove the 2FA making logging in easier just make sure that this user has the proper rights and limit login to your IP address – Walter Verhoeven Feb 06 '20 at 07:51
  • add IB Gateway On startup, and reboot your server everyday – SSDN Aug 16 '21 at 17:49

1 Answers1

6

IB gateway will/ should reboot 1x per week, TWS each day. in the weekends you will loose your connection to Interactive Brokers as the take the servers offline for servicing.

You will need to kill the process at end of trading and restart it Sunday (depending on your time zone) before markets open.

There are some scripts that seem to work like for a while depending on the method of authentication with Interactive Brokers.

We have solved it by looking at the window handles belonging to the IBGATEWAYY process and if it's the login window then we basically send keys to the login dialogbox.

Have a look at UI automated testing tools like Selenium, I use C# so for me it's easy, have a look at this for Inspiration if the above script and selenium doesn't work for you.

Walter Verhoeven
  • 3,867
  • 27
  • 36