{"id":175997,"date":"2021-04-28T18:59:00","date_gmt":"2021-04-28T22:59:00","guid":{"rendered":"https:\/\/ibkrcampus.com\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/"},"modified":"2023-04-25T20:56:08","modified_gmt":"2023-04-26T00:56:08","slug":"introduction-to-the-tws-excel-api-initial-setup","status":"publish","type":"trading-lessons","link":"https:\/\/www.interactivebrokers.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/","title":{"rendered":"Introduction to the TWS Excel API &#038; Initial Setup"},"content":{"rendered":"<h4><strong>Prerequisites<\/strong><\/h4>\n<p><a href=\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/excel?%20legRedir=true&amp;CorrelationId=6f726860-1745-4832-bedc-cc18e3849e15&amp;rtc=1\">Microsoft Office Excel (Windows Only)<\/a><\/p>\n<p><a href=\"https:\/\/www.java.com\/en\/\">Java Runtime Environment (JRE)<\/a><\/p>\n<p>Before we begin, there are some prerequisites the TWS API requires. For example, if are looking to use our excel APIs, you would need Java and a Windows copy of Microsoft Excel installed.<\/p>\n<h4><strong>Overview of the TWS API<\/strong><\/h4>\n<p>The Interactive Brokers&#8217; TWS APIs allows other applications and programs to work with the Trader Workstation (TWS) or IB Gateway. Trader Workstation is our flagship trading platform and IB Gateway is the <strong>lightweight<\/strong> version without any of the manual trading features.<\/p>\n<p>In this course, we will cover connecting Microsoft Excel to TWS so we can retrieve market data, place orders, view account and portfolio data and much more! We&#8217;ll explore a sample spreadsheet that has been created by IBKR to highlight the functionality of the Excel TWS API. You can reference the sample spreadsheet as we show you examples in this course. We&#8217;ll also cover making an API request, such as retrieving market data, using a blank Excel spreadsheet. This way you&#8217;ll know how to connect your existing spreadsheet with TWS.<\/p>\n<p>Let&#8217;s briefly cover the TWS API a bit more in depth, and its capabilities.<\/p>\n<h4>Downloading and installing TWS<\/h4>\n<p>Before we get started, make sure you have TWS or IB Gateway installed, If you don&#8217;t, you can head over to our website, <a href=\"https:\/\/www.ibkr.com\" target=\"_blank\" rel=\"noopener\">ibkr.com<\/a>, select &#8220;Log In&#8221; in the upper right hand corner of the page and from the drop down menu, select Trader Workstation or API: IB Gateway.<\/p>\n<p>They can also be found on our main website, under the menu Trading, then Platforms.<\/p>\n<p>In addition, there are some prerequisites the TWS API requires. For example, if are looking to use our excel APIs, you would need Java and a Windows copy of Microsoft Excel installed.<\/p>\n<p>The latest version of our Excel APIs are supported with both 32-bit and 64-bit Operating Systems. However, they are not compatible with the Mac Operating System. Our website will automatically provide a download version but you may choose a different version if you&#8217;d like.<\/p>\n<h4>Installing the TWS API<\/h4>\n<p>To obtain all the components required to use the Excel APIs, including sample sheets and source code, on our website, you may navigate to <a href=\"https:\/\/www.ibkr.com\/\" target=\"_blank\" rel=\"noopener\">ibkr.com <\/a>and access the menus at the top and select <strong>Trading &gt; APIs<\/strong> and select<strong> Download and Resources<\/strong>.<\/p>\n<p>Our APIs are provided with a Non-Commercial license agreement. You may download either the stable or latest version.<\/p>\n<p>Note, the Excel APIs are only supported for the windows operating system.\u00a0 The most up-to-date version of Interactive Brokers API source code is hosted on <a href=\"https:\/\/interactivebrokers.github.io\/tws-api\/\" target=\"_blank\" rel=\"noopener\">Github<\/a> as a private repository. We refer to this as our &#8220;beta client&#8221; although it doesn&#8217;t use formal release numbers as do our &#8220;Latest&#8221; and &#8220;Stable&#8221; API versions.<\/p>\n<p>This code is frequently updated with new features and functionality, and periodically the API source code in this private repository is published as a new version of API Latest. Users can gain access to the <a href=\"https:\/\/interactivebrokers.github.io\/tws-api\/\" target=\"_blank\" rel=\"noopener\">Github<\/a> repository to view the current Beta API source code as well as to contribute suggestions and source code.<\/p>\n<p>Our goal in allowing our users to contribute is to improve the reliability and versatility of the API for everyone.\u00a0 Review this page if you\u2019d like to access and contribute to the API Beta version.<\/p>\n<p>After successfully installing, you will find the API samples and components installed on the same drive as the operating system which is usually the c drive.<\/p>\n<ul>\n<li>Here you&#8217;ll see the folders samples, source, source, and tests.<\/li>\n<li>The source folder contains the necessary files to create your own API application, and in essence define the available messages the API can send and receive.<\/li>\n<li>In this course, we will discuss the content from the samples folder, which contains the sample spreadsheets for DDE, ActiveX, and RTD inside the &#8220;Excel&#8221; folder.<\/li>\n<li>The DdeSocketBridge folder inside samples contains the batch file necessary to run the new DDE sample. We&#8217;ll cover this more later. Also note, the tests folder contains the library TwsLib.dll , which is used by the ActiveX sample.<\/li>\n<\/ul>\n<h4>Configuring TWS Settings for API<\/h4>\n<p>TWS is <strong>required<\/strong> to be open on your computer to integrate with Excel. Just double click on the Trader Workstation desktop icon to launch and log into TWS.<\/p>\n<p>Now that TWS is running, let&#8217;s enable the API functionality. Go to the menu at the top of TWS and select <strong><em>Edit <\/em><\/strong>&gt; <strong><em>Global Configuration <\/em><\/strong>&gt; <strong><em>API <\/em><\/strong>&gt; <strong><em>Settings<\/em><\/strong>, and then check the box on the left <strong><em>Enable ActiveX and Socket Clients<\/em><\/strong>.<\/p>\n<p>By default, the sample sheet that we&#8217;ll use port 7496 so you&#8217;ll see that set here. When done click on <strong><em>Apply <\/em><\/strong>and then click on <strong><em>Ok<\/em><\/strong>.<\/p>\n<p>Now that we have TWS configured, the next video in this course will go over using Excel RTD, which stands for <em>real time data. Hope you can join us!<\/em><\/p>\n<h4>Additional links:<\/h4>\n<p><a href=\"https:\/\/interactivebrokers.github.io\/tws-api\/\" target=\"_blank\" rel=\"noopener\">TWS API Software<\/a><\/p>\n<p><a href=\"https:\/\/www.interactivebrokers.com\/en\/index.php?f=5039\" target=\"_blank\" rel=\"noopener\">API Users Guide<\/a><\/p>\n<p><a href=\"https:\/\/www.interactivebrokers.com\/en\/index.php?f=5059\" target=\"_blank\" rel=\"noopener\">API Release Notes \u2013 Production<\/a><\/p>\n<p><a href=\"https:\/\/www.interactivebrokers.com\/en\/index.php?f=5061\" target=\"_blank\" rel=\"noopener\">API Beta Release Notes<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this video, we\u2019ll show you the basis &#8211; how to download, install and configure the TWS API.<\/p>\n","protected":false},"author":851,"featured_media":221403,"parent":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"contributors-categories":[13576],"traders-academy":[13125,13128,13132],"class_list":{"0":"post-175997","1":"trading-lessons","2":"type-trading-lessons","3":"status-publish","4":"has-post-thumbnail","6":"contributors-categories-interactive-brokers","7":"traders-academy-beginner-trading","8":"traders-academy-level","9":"traders-academy-trading-lesson"},"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Archives | Traders&#039; Academy | IBKR Campus<\/title>\n<meta name=\"description\" content=\"In this video, we\u2019ll show you the basis - how to download, install and configure the TWS API.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/trading-lessons\/175997\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction to the TWS Excel API &amp; Initial Setup\" \/>\n<meta property=\"og:description\" content=\"In this video, we\u2019ll show you the basis - how to download, install and configure the TWS API.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-26T00:56:08+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Introduction to the TWS Excel API &amp; Initial Setup\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/introduction-to-the-tws-excel-api-initial-setup\\\/\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/introduction-to-the-tws-excel-api-initial-setup\\\/\",\n\t            \"name\": \"Introduction to the TWS Excel API & Initial Setup\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/introduction-to-the-tws-excel-api-initial-setup\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/introduction-to-the-tws-excel-api-initial-setup\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/04\\\/mqdefault-3.jpg\",\n\t            \"datePublished\": \"2021-04-28T22:59:00+00:00\",\n\t            \"dateModified\": \"2023-04-26T00:56:08+00:00\",\n\t            \"description\": \"In this video, we\u2019ll show you the basis - how to download, install and configure the TWS API.\",\n\t            \"breadcrumb\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/introduction-to-the-tws-excel-api-initial-setup\\\/#breadcrumb\"\n\t            },\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/introduction-to-the-tws-excel-api-initial-setup\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/introduction-to-the-tws-excel-api-initial-setup\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/04\\\/mqdefault-3.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/04\\\/mqdefault-3.jpg\",\n\t            \"width\": 320,\n\t            \"height\": 180,\n\t            \"caption\": \"Introduction to the TWS Excel API & Initial Setup\"\n\t        },\n\t        {\n\t            \"@type\": \"BreadcrumbList\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/introduction-to-the-tws-excel-api-initial-setup\\\/#breadcrumb\",\n\t            \"itemListElement\": [\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 1,\n\t                    \"name\": \"Academy Lessons\",\n\t                    \"item\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/trading-lessons\\\/\"\n\t                },\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 2,\n\t                    \"name\": \"Introduction to the TWS Excel API &#038; Initial Setup\"\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Archives | Traders' Academy | IBKR Campus","description":"In this video, we\u2019ll show you the basis - how to download, install and configure the TWS API.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/trading-lessons\/175997\/","og_locale":"en_US","og_type":"article","og_title":"Introduction to the TWS Excel API & Initial Setup","og_description":"In this video, we\u2019ll show you the basis - how to download, install and configure the TWS API.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/","og_site_name":"IBKR Campus US","article_modified_time":"2023-04-26T00:56:08+00:00","twitter_card":"summary_large_image","twitter_title":"Introduction to the TWS Excel API & Initial Setup","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/ibkrcampus.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/","url":"https:\/\/ibkrcampus.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/","name":"Introduction to the TWS Excel API & Initial Setup","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ibkrcampus.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/#primaryimage"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/mqdefault-3.jpg","datePublished":"2021-04-28T22:59:00+00:00","dateModified":"2023-04-26T00:56:08+00:00","description":"In this video, we\u2019ll show you the basis - how to download, install and configure the TWS API.","breadcrumb":{"@id":"https:\/\/ibkrcampus.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ibkrcampus.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/mqdefault-3.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/04\/mqdefault-3.jpg","width":320,"height":180,"caption":"Introduction to the TWS Excel API & Initial Setup"},{"@type":"BreadcrumbList","@id":"https:\/\/ibkrcampus.com\/campus\/trading-lessons\/introduction-to-the-tws-excel-api-initial-setup\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Academy Lessons","item":"https:\/\/ibkrcampus.com\/campus\/trading-lessons\/"},{"@type":"ListItem","position":2,"name":"Introduction to the TWS Excel API &#038; Initial Setup"}]},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"}]}},"_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/trading-lessons\/175997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/trading-lessons"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/trading-lessons"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/851"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=175997"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/trading-lessons\/175997\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/221403"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=175997"}],"wp:term":[{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=175997"},{"taxonomy":"traders-academy","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/traders-academy?post=175997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}