{"id":336,"date":"2016-10-15T17:19:26","date_gmt":"2016-10-15T15:19:26","guid":{"rendered":"http:\/\/script-trading.com\/en\/?p=336"},"modified":"2024-01-28T19:09:34","modified_gmt":"2024-01-28T18:09:34","slug":"automation-of-interactive-broker-trading-workstation-tws-with-ibcontroller-github","status":"publish","type":"post","link":"https:\/\/script-trading.com\/en\/automation-of-interactive-broker-trading-workstation-tws-with-ibcontroller-github\/","title":{"rendered":"Automation of Interactive Brokers (IB) Trading Workstation (TWS) using IBController"},"content":{"rendered":"<p><img decoding=\"async\" class=\"aligncenter size-medium wp-image-359\" src=\"http:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tradingtech_tws_001-300x166.png\" alt=\"tradingtech_tws_001\" width=\"300\" height=\"166\" srcset=\"https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tradingtech_tws_001-300x166.png 300w, https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tradingtech_tws_001-230x127.png 230w, https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tradingtech_tws_001-350x193.png 350w, https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tradingtech_tws_001-480x265.png 480w, https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tradingtech_tws_001.png 650w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>You are using AgenaTrader in combination with brokerage software\u00a0Trading Workstation (TWS) from\u00a0<a href=\"https:\/\/www.interactivebrokers.com\/en\/home.php\" target=\"_blank\" rel=\"noopener\">Interactive Broker (IB)<\/a>\u00a0or the german based broker\u00a0<a href=\"https:\/\/www.captrader.com\/en\/\" target=\"_blank\" rel=\"noopener\">Captrader<\/a>\u00a0and <strong>you want to trade with financial products 24 hours, 7 days a week (24\/7)<\/strong>?<\/p>\n<p>Then you certainly know one of the following problems:<\/p>\n<ul>\n<li>Connection between AgenaTrader and TWS is broken due an unknown problem and you do not want to wait\u00a0to\u00a0connect to the broker with TWS the next day.<\/li>\n<li>Your goal is the use of AgenaTrader and TWS in 24\/7 operation on a server, but you do not want the manual reconnection.<\/li>\n<li>You use RDP (Windows Remote Desktop), but in this case AgenaTrader does not automatically reconnect to TWS after midnight maintenance.<\/li>\n<\/ul>\n<p>TWS is programmed to complete and close once per day, in most cases at midnight. For this purpose, a pretty good function was programmed into\u00a0the AgenaTrader which makes an automatic login and restores the connection to the broker.\u00a0<strong>This only works if the server has\u00a0an user session active.<\/strong>\u00a0The main problem with remote sessions using\u00a0RDP on\u00a0&#8220;headless systems&#8221; is that the\u00a0user session is handled\u00a0differently.\u00a0This is actually a classic problem on any &#8220;real&#8221; server, any computer without a monitor, any Virtual Private Server (VPS), or a <a href=\"https:\/\/azure.microsoft.com\/en\/\" target=\"_blank\" rel=\"noopener\">Microsoft Azure<\/a> cloud server.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-medium wp-image-362\" src=\"http:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tws_login_form-300x161.png\" alt=\"tws_login_form\" width=\"300\" height=\"161\" srcset=\"https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tws_login_form-300x161.png 300w, https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tws_login_form-230x124.png 230w, https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tws_login_form-350x188.png 350w, https:\/\/script-trading.com\/wp-content\/uploads\/2016\/10\/tws_login_form.png 478w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>If no user is logged on, nothing happens with the forms which require user input like the login form of the TWS and in this case AgenaTrader is not able to log in\u00a0automatically to the broker (Interactive Broker or Captrader). If you open an RDP connection, then AgenaTrader automatically connects, because\u00a0now an user session is active on the server.<\/p>\n<p>This is not a TWS-specific problem, it is\u00a0a problem of all software programs that require a login step\u00a0via an user forms. Of course, the software manufacturer could positively influence this situation in which automatic logoff \/ logon procedures are implemented or the API is opened to a size that this could be done via external\u00a0program\u00a0(at your own risk, of course). There is certainly a lot of discussion about the structure and usability of the graphical user interface of the TWS, but the API access is simply unbeatable!<\/p>\n<p>On GitHub an open source project was created which, among other advantages, solves all of the above problems in one fell swoop.<br \/>\nThe project is called IBController and allows a much deeper configuration of the TWS as well as an automatic logout \/ logon.<\/p>\n<p>IBController offers among other things the following advantages (according to the GitHub project from 15.10.2016):<\/p>\n<blockquote><p>Automates Trader Workstation (TWS) and IB Gateway (including the FIX mode)<br \/>\nCompletes login dialog with credentials from an .ini file or command line<br \/>\nHandles dialog boxes which TWS presents during programmatic trading activities<br \/>\nKeeps TWS running indefinitely by handling TWS time-based exits<br \/>\nAllows TWS to be terminated at a specified time on a specified day of the week<br \/>\nDismisses various dialog messages (eg version updates, daily tips, IB API connections etc)<br \/>\nExposes a telnet control protocol to STOP the GUI or ENABLEAPI for IB API client access<\/p><\/blockquote>\n<p>The IBController project works with the TWS of the Interactive Broker (IB) as well as with the TWS for the broker Captrader.<\/p>\n<p><a href=\"https:\/\/github.com\/ib-controller\/ib-controller\" target=\"_blank\" rel=\"noopener\">IBController is open source and has been made available on GitHub.<\/a><\/p>\n<p>We have created an quick start to make it easier for you to install IBController:<\/p>\n<ul>\n<li><a href=\"http:\/\/script-trading.com\/en\/installation-ibcontroller-for-automatic-24h-stock-trading-part-1\/\">Installation IBController for automatic 24h stock trading (part 1)<\/a><\/li>\n<li><a href=\"http:\/\/script-trading.com\/en\/installation-ibcontroller-for-automatic-24h-stock-trading-part-2\/\">Installation IBController for automatic 24h stock trading (part 2)<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You are using AgenaTrader in combination with brokerage software\u00a0Trading Workstation (TWS) from\u00a0Interactive Broker (IB)\u00a0or the german based broker\u00a0Captrader\u00a0and you want to trade [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":359,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[62,31,32],"tags":[26,23,25,24],"class_list":["post-336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-english","category-tws-en","category-tws","tag-captrader","tag-github","tag-interactive-broker","tag-tws"],"_links":{"self":[{"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":29,"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/posts\/336\/revisions"}],"predecessor-version":[{"id":1149,"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/posts\/336\/revisions\/1149"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/media\/359"}],"wp:attachment":[{"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/categories?post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/script-trading.com\/en\/wp-json\/wp\/v2\/tags?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}