{"id":71174,"date":"2021-01-04T10:30:27","date_gmt":"2021-01-04T15:30:27","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=71174"},"modified":"2022-11-21T09:46:51","modified_gmt":"2022-11-21T14:46:51","slug":"implementing-market-scanners-using-tws-api-part-i","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/","title":{"rendered":"Implementing Market Scanners using TWS API &#8211; Part I"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The TWS market scanner functionality provided by Interactive Brokers is a very popular feature&nbsp;allowing&nbsp;traders to scan multiple products (stocks, ETFs, bonds, options etc.) across various markets (both US and non US).&nbsp;This feature allows users to configure their own scanners through a wide range of filters&nbsp;and parameters.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Setting up and configuring a scanner tool in TWS is quite straightforward and it can be done by clicking on the \u201cNew Window\u201d menu and then choosing the Scanners option.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-4.png\" alt=\"\" class=\"wp-image-71189 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As apparent from the above screenshot, IB allows four different types of scanners and depending on your requirement you can chose and configure your scanner.&nbsp;Below I am sharing the screenshots of both the Mosaic Market Scanner and Advanced Market Scanner. As you can see from the images, the scanner GUI is quite intuitive and users&nbsp;can easily&nbsp;configure their scanners by choosing their parameters and tuning their filters.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Mosaic Market Scanner lets users chose the markets and tune the filters as per requirement.<\/em>&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-5.png\" alt=\"\" class=\"wp-image-71196 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Advanced Market Scanner gives users the additional feature of&nbsp;further refining their scan criteria by&nbsp;choosing from a wide suite&nbsp;of parameters such as top gainers, top gap ups and downs, fundamental ratios and even some technical indicator based parameters.<\/em>&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-6.png\" alt=\"\" class=\"wp-image-71200 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Since this article is about implementing scanner functionality algorithmically and not manually, I leave it to the readers to use some wonderful articles and YouTube tutorials available online on how to set up and configure TWS scanners manually.&nbsp;I will now explain how TWS&nbsp;API can be used to implement scanners programmatically.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Quick Introduction to IBAPI<\/strong>&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">TWS API (also called IBAPI)&nbsp;is an interface&nbsp;which can be used by&nbsp;Interactive&nbsp;Brokers&nbsp;clients&nbsp;to&nbsp;establish&nbsp;connection&nbsp;with&nbsp;TWS, extract information, place trades and manage accounts programmatically. In essence,&nbsp;TWS API&nbsp;is a set of programs (supported in multiple programming languages such&nbsp;as&nbsp;C++, C#, Python, Java and VB) which allows users to automate their trading.&nbsp;Needless to say, some basic programming proficiency in any of the above languages is required to harness&nbsp;the potential of&nbsp;TWS API.&nbsp;I have used Python API in this article but the same can be replicated using any of the other supported programming languages.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">TWS&nbsp;API&nbsp;helps establish a websocket connection between TWS and your trading application (which can be a simple Python code). Once the connection is established, data can be extracted and commands executed using the&nbsp;websocket connection. There are two mainstays of the TWS&nbsp;API architecture which are the&nbsp;EClient&nbsp;and&nbsp;the&nbsp;EWrapper&nbsp;classes (warning \u2013&nbsp;elements of&nbsp;object&nbsp;oriented programming concepts&nbsp;ahead&nbsp;J&nbsp;).&nbsp;I would spare you the technical details in this article but essentially,&nbsp;the&nbsp;EClient&nbsp;class&nbsp;lets you send&nbsp;messages&nbsp;(such as requesting data, placing orders etc.)&nbsp;to&nbsp;the&nbsp;TWS and&nbsp;the&nbsp;EWrapper&nbsp;class helps deliver the response received from&nbsp;the&nbsp;TWS in a readable format. Below is an example of a basic trading application created using the&nbsp;EClient&nbsp;and&nbsp;EWrapper&nbsp;classes.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-7.png\" alt=\"\" class=\"wp-image-71207 lazyload\" width=\"500\" height=\"199\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-7.png 500w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-7-300x119.png 300w\" data-sizes=\"(max-width: 500px) 100vw, 500px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 500px; aspect-ratio: 500\/199;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This trading application does not do anything but simply&nbsp;establishes a persistent websocket connection with&nbsp;the&nbsp;TWS programmatically. It can be figured out from the above code that the&nbsp;TradingApp&nbsp;class inherits from the&nbsp;EWrapper&nbsp;and&nbsp;EClient&nbsp;classes meaning this trading application can harness all the functions of its two parent classes.&nbsp;Therefore when we&nbsp;created the object named \u201capp\u201d of&nbsp;TradingApp&nbsp;class,&nbsp;we made it&nbsp;capable of executing any function defined in the&nbsp;EClient&nbsp;class and then handling and presenting that information using the relevant&nbsp;EWrapper&nbsp;function. Another thing to note in this code is that we are connecting to port 7497 of your local machine.&nbsp;\u201c127.0.0.1\u201d&nbsp;is the standard localhost address which refers to local machine. If you want to connect to the TWS remotely, you will have to provide the relevant IP address of the machine and make corresponding changes in the security settings of your TWS. Port 7497&nbsp;is used to connect to the paper trading account whereas port 7496 is used for the&nbsp;real&nbsp;trading account.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let us expand the scope of our&nbsp;TradingApp&nbsp;and extract contract details for a given instrument. Refer below code&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-8.png\" alt=\"\" class=\"wp-image-71210 lazyload\" width=\"517\" height=\"411\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-8.png 517w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-8-300x238.png 300w\" data-sizes=\"(max-width: 517px) 100vw, 517px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 517px; aspect-ratio: 517\/411;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You can notice a few changes in the code&nbsp;compared to the basic trading app&nbsp;but&nbsp;I would like to draw your attention towards&nbsp;the&nbsp;app.reqContractDetails() function call and the&nbsp;contractDetails&nbsp;function definition within&nbsp;TradingApp.&nbsp;Since we want&nbsp;our trading app to extract contract information, we have&nbsp;to use the&nbsp;reqContractDetails() function call on our app. This is an&nbsp;ECleint&nbsp;function specifically defined to extract contract information. However, this function call necessitated our&nbsp;TradingApp&nbsp;to define the corresponding&nbsp;EWrapper&nbsp;function (contractDetails) which is defined to handle the response from the&nbsp;reqContractDetails&nbsp;function call.&nbsp;The relevant&nbsp;EClient&nbsp;and&nbsp;EWrapper&nbsp;functions for various applications (such as requesting historical data, streaming market data, placing orders etc.) can be&nbsp;obtained&nbsp;from the TWS API documentation (<a href=\"https:\/\/interactivebrokers.github.io\/tws-api\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/interactivebrokers.github.io\/tws-api\/index.html<\/a>)&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Below is the&nbsp;output&nbsp;that we will receive if we run&nbsp;above&nbsp;code.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"625\" height=\"407\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-9.png\" alt=\"\" class=\"wp-image-71218 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-9.png 625w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-9-300x195.png 300w\" data-sizes=\"(max-width: 625px) 100vw, 625px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 625px; aspect-ratio: 625\/407;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">No need to get alarmed seeing&nbsp;all the&nbsp;Error messages. Error -1 code&nbsp;refers to&nbsp;generic messages sent by TWS once a connection is&nbsp;successfully established. We handle&nbsp;these messages using the error function (which is another&nbsp;EWrapper&nbsp;function defined in our Trading App).&nbsp;As you can see, the contract details for Apple stock was&nbsp;printed&nbsp;on the console. If you are not happy with how the message is handled by the&nbsp;contractDetails&nbsp;function, you can&nbsp;make the required changes in the&nbsp;contractDetails&nbsp;function.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Stay tuned for the next installment in this series in which the author will discuss Market Scanners using TWS API.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The author can be reached at&nbsp;<a href=\"mailto:contact@rasuquant.com\">contact@rasuquant.com<\/a>.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>If you found this article interesting, you may&nbsp;consider enrolling in the author&#8217;s TWS API&nbsp;course&nbsp;(<a href=\"https:\/\/school-of-algorithmic-trading.teachable.com\/courses\/algorithmic-trading-using-interactive-brokers-python-api\/lectures\/27668823\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/school-of-algorithmic-trading.teachable.com\/courses\/algorithmic-trading-using-interactive-brokers-python-api\/lectures\/27668823<\/a>). The course starts from the basics of TWS API and some key programming concepts such as OOPs basics and threading and then gradually delves&nbsp;into more advanced concepts to help you build fully automated trading applications on Interactive Brokers&#8217; platform.&nbsp;&nbsp;<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Join Rasuquant for a Python tutorial on how to configure market scanners through a wide range of filters and parameters via IBKR API.<\/p>\n","protected":false},"author":565,"featured_media":71179,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[340,343,349,338,350,341,344],"tags":[851,8541,8542,575,9024,595],"contributors-categories":[13715],"class_list":["post-71174","post","type-post","status-publish","format-standard","has-post-thumbnail","category-api-development","category-programing-languages","category-python-development","category-ibkr-quant-news","category-quant-asia-pacific","category-quant-development","category-quant-regions","tag-algo-trading","tag-eclient-class","tag-ewrapper-class","tag-ibkr-api","tag-market-scanners","tag-python","contributors-categories-rasuquant"],"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 v28.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Implementing Market Scanners using TWS API &#8211; Part I<\/title>\n<meta name=\"description\" content=\"Join Rasuquant for a Python tutorial on how to configure market scanners through a wide range of filters and parameters via IBKR 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\/posts\/71174\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Implementing Market Scanners using TWS API - Part I | IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"Join Rasuquant for a Python tutorial on how to configure market scanners through a wide range of filters and parameters via IBKR API.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-04T15:30:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-21T14:46:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/world-grid.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"550\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mayank Rasu\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mayank Rasu\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 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\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Mayank Rasu\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/41a7b1d2d6971906a0d461646888e9fc\"\n\t            },\n\t            \"headline\": \"Implementing Market Scanners using TWS API &#8211; Part I\",\n\t            \"datePublished\": \"2021-01-04T15:30:27+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:46:51+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/\"\n\t            },\n\t            \"wordCount\": 1160,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/01\\\/world-grid.jpg\",\n\t            \"keywords\": [\n\t                \"Algo Trading\",\n\t                \"EClient Class\",\n\t                \"EWrapper Class\",\n\t                \"IBKR API\",\n\t                \"Market Scanners\",\n\t                \"Python\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"IBKR API Development\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Asia Pacific\",\n\t                \"Quant Development\",\n\t                \"Quant Regions\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/\",\n\t            \"name\": \"Implementing Market Scanners using TWS API - Part I | IBKR Quant Blog\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/01\\\/world-grid.jpg\",\n\t            \"datePublished\": \"2021-01-04T15:30:27+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:46:51+00:00\",\n\t            \"description\": \"Join Rasuquant for a Python tutorial on how to configure market scanners through a wide range of filters and parameters via IBKR API.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-i\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/01\\\/world-grid.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/01\\\/world-grid.jpg\",\n\t            \"width\": 900,\n\t            \"height\": 550,\n\t            \"caption\": \"Quant\"\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            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/41a7b1d2d6971906a0d461646888e9fc\",\n\t            \"name\": \"Mayank Rasu\",\n\t            \"sameAs\": [\n\t                \"https:\\\/\\\/rasuquant.com\"\n\t            ],\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/mayankrasu\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Implementing Market Scanners using TWS API &#8211; Part I","description":"Join Rasuquant for a Python tutorial on how to configure market scanners through a wide range of filters and parameters via IBKR 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\/posts\/71174\/","og_locale":"en_US","og_type":"article","og_title":"Implementing Market Scanners using TWS API - Part I | IBKR Quant Blog","og_description":"Join Rasuquant for a Python tutorial on how to configure market scanners through a wide range of filters and parameters via IBKR API.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/","og_site_name":"IBKR Campus US","article_published_time":"2021-01-04T15:30:27+00:00","article_modified_time":"2022-11-21T14:46:51+00:00","og_image":[{"width":900,"height":550,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/world-grid.jpg","type":"image\/jpeg"}],"author":"Mayank Rasu","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mayank Rasu","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/"},"author":{"name":"Mayank Rasu","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/41a7b1d2d6971906a0d461646888e9fc"},"headline":"Implementing Market Scanners using TWS API &#8211; Part I","datePublished":"2021-01-04T15:30:27+00:00","dateModified":"2022-11-21T14:46:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/"},"wordCount":1160,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/world-grid.jpg","keywords":["Algo Trading","EClient Class","EWrapper Class","IBKR API","Market Scanners","Python"],"articleSection":["IBKR API Development","Programming Languages","Python Development","Quant","Quant Asia Pacific","Quant Development","Quant Regions"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/","name":"Implementing Market Scanners using TWS API - Part I | IBKR Quant Blog","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/world-grid.jpg","datePublished":"2021-01-04T15:30:27+00:00","dateModified":"2022-11-21T14:46:51+00:00","description":"Join Rasuquant for a Python tutorial on how to configure market scanners through a wide range of filters and parameters via IBKR API.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/world-grid.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/world-grid.jpg","width":900,"height":550,"caption":"Quant"},{"@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\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/41a7b1d2d6971906a0d461646888e9fc","name":"Mayank Rasu","sameAs":["https:\/\/rasuquant.com"],"url":"https:\/\/www.interactivebrokers.com\/campus\/author\/mayankrasu\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/world-grid.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/71174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/565"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=71174"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/71174\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/71179"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=71174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=71174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=71174"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=71174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}