{"id":71259,"date":"2021-01-11T09:00:00","date_gmt":"2021-01-11T14:00:00","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=71259"},"modified":"2022-11-21T09:46:53","modified_gmt":"2022-11-21T14:46:53","slug":"implementing-market-scanners-using-tws-api-part-ii","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/","title":{"rendered":"Implementing Market Scanners using TWS API \u2013 Part II"},"content":{"rendered":"\n<p><em>Get started with <a href=\"\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-i\/\">Part I<\/a> of this series and learn more about IBKR API and review sample Python code.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-market-scanners-using-tws-api\">Market Scanners using TWS API<\/h2>\n\n\n\n<p>Please note that at this time, we are unable to replicate every advanced scanner available in the TWS using the API. However, the good news is that the scope is getting expanded with subsequent new releases of the API and hopefully soon we will be able to implement all advanced scanners using API. Nevertheless, the existing scope is sufficiently large and you should be able to implement reasonably advanced scanners using the API.<\/p>\n\n\n\n<p>Before, we start implementing the market scanner, it may be a good idea to get a list of all the parameters available in API. This can be done using EClient\u2019s reqScannerParameters function and the corresponding EWrapper\u2019s scannerParameters function. Refer the code below.<\/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-10.png\" alt=\"\" class=\"wp-image-71265 lazyload\" width=\"427\" height=\"313\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-10.png 427w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-10-300x220.png 300w\" data-sizes=\"(max-width: 427px) 100vw, 427px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 427px; aspect-ratio: 427\/313;\" \/><\/figure>\n\n\n\n<p>If you have been able to follow this article so far, interpreting the above code should be quite easy. All that we are doing in this trading app is preparing it to handle scanning parameters data dump once we request this data from the TWS using the reqScannerParameters EClient function. The scannerParameters function exports the parameters data into an XML file. Below is partial snapshot of the XML data dump<\/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-11.png\" alt=\"\" class=\"wp-image-71266 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>The&nbsp;above snapshot shows the list of available filters for scanning US Stocks. Please note that the XML document is quite detailed and it provides the available filters and parameters by asset class.&nbsp;<\/p>\n\n\n\n<p>Now that we have been able to get the exhaustive list of filters and parameters available with us, let us try implementing a market scanner&nbsp;<\/p>\n\n\n\n<p><strong>Scanning Top Ga<\/strong><strong>iners<\/strong>&nbsp;<\/p>\n\n\n\n<p>We will now create a trading application which will scan a given universe of stocks&nbsp;continuously&nbsp;and identify stocks which witnessed the largest&nbsp;gain&nbsp;since markets opened. However, rather than casting a very wide net, we will define some market data based filters which will refine our scanning criteria. Below is the code.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"701\" height=\"515\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-12.png\" alt=\"\" class=\"wp-image-71267 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-12.png 701w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-12-300x220.png 300w\" data-sizes=\"(max-width: 701px) 100vw, 701px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 701px; aspect-ratio: 701\/515;\" \/><\/figure>\n\n\n\n<p>To implement the scanner, we first need to import&nbsp;the&nbsp;ScannerSubscription&nbsp;class&nbsp;from the scanner module of the TWS API. The&nbsp;ScannerSubscription&nbsp;class allows us to&nbsp;create an object which&nbsp;defines the filters and parameters of&nbsp;our&nbsp;scanner. You can see that within the&nbsp;usStkScan&nbsp;function we have created an object&nbsp;scanSub&nbsp;of&nbsp;ScannerSubscription&nbsp;class.&nbsp;Within the function, we define the required filters and parameters of this object by referring to the XML document and using the relevant codes before returning the scanner object. In this example, we have defined our scanner object using the following parameters&nbsp;<\/p>\n\n\n\n<p><em>numberOfRows<\/em>&nbsp;\u2013 We want to limit our output to top 50 rows&nbsp;<\/p>\n\n\n\n<p><em>abovePrice<\/em>&nbsp;\u2013 Exclude stocks whose stock price is less than $10&nbsp;<\/p>\n\n\n\n<p><em>belowPrice<\/em>&nbsp;\u2013 Exclude stocks whose stock price is more than $200&nbsp;<\/p>\n\n\n\n<p><em>aboveVolume<\/em>&nbsp;\u2013 Exclude stocks whose daily volume is less than 1 million&nbsp;<\/p>\n\n\n\n<p><em>instrument<\/em>&nbsp;\u2013 Scan only stocks&nbsp;<\/p>\n\n\n\n<p><em>locationCode<\/em>&nbsp;\u2013 Scan stocks on all major US exchanges&nbsp;<\/p>\n\n\n\n<p><em>scanCode<\/em>&nbsp;\u2013 This is the scanning parameter. In this case we have chosen TOP_PERC_GAIN which as per the XML document scans for top percentage gainers&nbsp;<\/p>\n\n\n\n<p>The relevant&nbsp;EClient&nbsp;function to scan stocks is&nbsp;reqScannerSubscription. The arguments that this function takes are:&nbsp;<\/p>\n\n\n\n<p><em>reqID<\/em>&nbsp;\u2013 An integer value which is used to identify one API request from another.&nbsp;<\/p>\n\n\n\n<p><em>ScannerSubscription<\/em>\u2013 We need to pass the object of&nbsp;ScannerSubscription&nbsp;class that is returned by the&nbsp;usStkScan&nbsp;function&nbsp;in the above code.&nbsp;<\/p>\n\n\n\n<p>reqScannerSubscription&nbsp;takes in two more list arguments corresponding to filter options. However, you can pass them as blank lists since we will not be needing those.&nbsp;&nbsp;<\/p>\n\n\n\n<p>The&nbsp;scannerData&nbsp;function within the&nbsp;TradeApp&nbsp;class is the corresponding&nbsp;EWrapper&nbsp;function which is required to output the data when&nbsp;calling&nbsp;the&nbsp;reqScannerSubscription&nbsp;function&nbsp;<\/p>\n\n\n\n<p>In the above code, you can see that we have used python threading module as well. This is required because we want to execute the scanner and the websocket connection on different threads (this is a topic for a later discussion)&nbsp;<\/p>\n\n\n\n<p>Below is the output when I run the above code.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"798\" height=\"168\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-13.png\" alt=\"\" class=\"wp-image-71270 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-13.png 798w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-13-700x147.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-13-300x63.png 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-13-768x162.png 768w\" data-sizes=\"(max-width: 798px) 100vw, 798px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 798px; aspect-ratio: 798\/168;\" \/><\/figure>\n\n\n\n<p>Not very promising, is it? IB is complaining that I do not have the required permissions to execute this scan. This would be the appropriate time to discuss about the market data subscription requirement for implementing scanners. Since, the output from scanner, does not contain any market data, theoretically we do not need market data subscription to run scanners. However, if we want to use filters based on market data in our scanner then we will need to purchase the relevant subscriptions. For example, in the code above, if we remove the filters pertaining to stock price and volume (abovePrice,&nbsp;belowPrice&nbsp;and&nbsp;aboveVolume) we should be able to get an output. However, this would beat the purpose of our scanning since we will now have to exclude some key filters. Therefore in this case, we&nbsp;will have to purchase market data from relevant US exchanges. Thankfully, the subscription fee tends to be quite reasonable and you can subscribe to whichever market data you want from your IB account settings&gt;&gt;User Settings&gt;&gt;Market Data Subscription&nbsp;<\/p>\n\n\n\n<p>If we don\u2019t want to scan all the major US stock exchanges and only the ones that we are subscribed to, this can also be done by tweaking the&nbsp;locationCode&nbsp;attribute of the&nbsp;ScannerSubscription&nbsp;object. In the below example, I have updated the&nbsp;locationCode&nbsp;from US.STK.MAJOR to STK.NASDAQ as I am subscribed to&nbsp;receive data from the&nbsp;NASDAQ exchange.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"564\" height=\"149\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-14.png\" alt=\"\" class=\"wp-image-71271 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-14.png 564w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-14-300x79.png 300w\" data-sizes=\"(max-width: 564px) 100vw, 564px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 564px; aspect-ratio: 564\/149;\" \/><\/figure>\n\n\n\n<p>You can get the list of relevant location codes from the XML file that we&nbsp;have&nbsp;generated.&nbsp;<\/p>\n\n\n\n<p>Below is the&nbsp;output&nbsp;of the scanner after updating the location code to the exchange for which I am subscribed.&nbsp;The output continues to get refreshed every 30 seconds.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"893\" height=\"411\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-15.png\" alt=\"\" class=\"wp-image-71272 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-15.png 893w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-15-700x322.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-15-300x138.png 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/01\/image-15-768x353.png 768w\" data-sizes=\"(max-width: 893px) 100vw, 893px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 893px; aspect-ratio: 893\/411;\" \/><\/figure>\n\n\n\n<p>As you can see, the output lists out the top percentage gainers on the NASDAQ exchange by their rank.&nbsp;This list will keep getting updated as stocks move in an out of the top percentage gainer list.&nbsp;<\/p>\n\n\n\n<p>Please note that the scanner outputs only lists the contract information. However, the contract information can easily&nbsp;be&nbsp;combined with other TWS API modules, to implement a trading strategy based on scanner outputs.&nbsp;<\/p>\n\n\n\n<p>The author can be reached at&nbsp;<a href=\"mailto:contact@rasuquant.com\">contact@rasuquant.com<\/a>.&nbsp;<\/p>\n\n\n\n<p><em>If you found this article interesting, you may&nbsp;consider enrolling in the author\u2019s 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\u2019 platform.&nbsp;&nbsp;<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Join Rasuquant&#8217;s Mayank Rasu for a tutorial on how to create Market Scanners using IBKR TWS API.<\/p>\n","protected":false},"author":565,"featured_media":51661,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[340,343,349,338,350,341,344],"tags":[851,8541,8542,575,9024,595],"contributors-categories":[13715],"class_list":{"0":"post-71259","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-api-development","8":"category-programing-languages","9":"category-python-development","10":"category-ibkr-quant-news","11":"category-quant-asia-pacific","12":"category-quant-development","13":"category-quant-regions","14":"tag-algo-trading","15":"tag-eclient-class","16":"tag-ewrapper-class","17":"tag-ibkr-api","18":"tag-market-scanners","19":"tag-python","20":"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 v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Implementing Market Scanners using TWS API \u2013 Part II<\/title>\n<meta name=\"description\" content=\"Join Rasuquant&#039;s Mayank Rasu for a tutorial on how to create Market Scanners using IBKR 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\/posts\/71259\/\" \/>\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 \u2013 Part II | IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"Join Rasuquant&#039;s Mayank Rasu for a tutorial on how to create Market Scanners using IBKR TWS API.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-11T14:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-21T14:46:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/07\/stock-charts-room.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-ii\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-ii\\\/\"\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 \u2013 Part II\",\n\t            \"datePublished\": \"2021-01-11T14:00:00+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:46:53+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-ii\\\/\"\n\t            },\n\t            \"wordCount\": 1191,\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-ii\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/07\\\/stock-charts-room.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-ii\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-ii\\\/\",\n\t            \"name\": \"Implementing Market Scanners using TWS API \u2013 Part II | 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-ii\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/implementing-market-scanners-using-tws-api-part-ii\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/07\\\/stock-charts-room.jpg\",\n\t            \"datePublished\": \"2021-01-11T14:00:00+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:46:53+00:00\",\n\t            \"description\": \"Join Rasuquant's Mayank Rasu for a tutorial on how to create Market Scanners using IBKR TWS 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-ii\\\/\"\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-ii\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/07\\\/stock-charts-room.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/07\\\/stock-charts-room.jpg\",\n\t            \"width\": 900,\n\t            \"height\": 550,\n\t            \"caption\": \"Statistics\"\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 \u2013 Part II","description":"Join Rasuquant's Mayank Rasu for a tutorial on how to create Market Scanners using IBKR 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\/posts\/71259\/","og_locale":"en_US","og_type":"article","og_title":"Implementing Market Scanners using TWS API \u2013 Part II | IBKR Quant Blog","og_description":"Join Rasuquant's Mayank Rasu for a tutorial on how to create Market Scanners using IBKR TWS API.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/","og_site_name":"IBKR Campus US","article_published_time":"2021-01-11T14:00:00+00:00","article_modified_time":"2022-11-21T14:46:53+00:00","og_image":[{"width":900,"height":550,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/07\/stock-charts-room.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-ii\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/"},"author":{"name":"Mayank Rasu","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/41a7b1d2d6971906a0d461646888e9fc"},"headline":"Implementing Market Scanners using TWS API \u2013 Part II","datePublished":"2021-01-11T14:00:00+00:00","dateModified":"2022-11-21T14:46:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/"},"wordCount":1191,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/07\/stock-charts-room.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-ii\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/","name":"Implementing Market Scanners using TWS API \u2013 Part II | 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-ii\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/07\/stock-charts-room.jpg","datePublished":"2021-01-11T14:00:00+00:00","dateModified":"2022-11-21T14:46:53+00:00","description":"Join Rasuquant's Mayank Rasu for a tutorial on how to create Market Scanners using IBKR TWS API.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/implementing-market-scanners-using-tws-api-part-ii\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/07\/stock-charts-room.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/07\/stock-charts-room.jpg","width":900,"height":550,"caption":"Statistics"},{"@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\/2020\/07\/stock-charts-room.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/71259","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=71259"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/71259\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/51661"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=71259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=71259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=71259"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=71259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}