{"id":117502,"date":"2022-01-03T12:09:00","date_gmt":"2022-01-03T17:09:00","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=117502"},"modified":"2022-11-21T09:50:30","modified_gmt":"2022-11-21T14:50:30","slug":"historical-options-futures-data-using-tws-api-part-ii","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/","title":{"rendered":"Historical Options &#038; Futures Data using TWS API \u2013 Part II"},"content":{"rendered":"\n<p>In <a href=\"\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api\/\">the previous article<\/a>, we learnt&nbsp;to build&nbsp;a trading application that fetches historical data for future contracts&nbsp;from the IB servers. We will now see how we can extract historical data for options contracts. We will first cover the easy part which is getting data for live option contracts. Following this, we will discuss a possible approach to&nbsp;<em>arrange<\/em>&nbsp;historical data for expired option contracts.&nbsp;As discussed in the previous article, I am assuming that you are subscribed to the relevant market data&nbsp;packs.&nbsp;<\/p>\n\n\n\n<p><strong>Trading Application<\/strong>&nbsp;<\/p>\n\n\n\n<p>Our trading application need not be changed from what we used to extract futures data. However, in the last article, we simply printed out the historical data and&nbsp;at that time&nbsp;I had promised that&nbsp;I&nbsp;will&nbsp;discuss&nbsp;how to store&nbsp;the extracted&nbsp;data. Therefore, in this article, we will tweak our trading application slightly to store data in Pandas dataframe instead of printing it out on the console. I have used Pandas dataframe&nbsp;and not&nbsp;native&nbsp;python&nbsp;data structures to store data because dataframes allow&nbsp;us&nbsp;some very convenient data handling and processing&nbsp;functions which will help us later in this article. If you are not conversant with Pandas Dataframes then I would highly recommend that you pick up at least some basic proficiency in this data structure.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"644\" height=\"412\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-1.png\" alt=\"\" class=\"wp-image-117512 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-1.png 644w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-1-300x192.png 300w\" data-sizes=\"(max-width: 644px) 100vw, 644px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 644px; aspect-ratio: 644\/412;\" \/><\/figure>\n\n\n\n<p>The first change in the trading application is adding a class variable&nbsp;<em>hist_data<\/em>. In Object Oriented Programming, Classes can have variables which define specific attribute of that class. Our&nbsp;TradeApp&nbsp;class is going to have&nbsp;<em>hist_data<\/em>&nbsp;as an attribute which will be a dataframe having the columns \u201cDate\u201d, \u201cOpen\u201d, \u201cHigh\u201d,\u201d Low\u201d,\u201d Close\u201d and \u201cVolume\u201d. The idea is that as and when TWS return us the historical bar data, we append each bar as a row to this class attribute.&nbsp;<\/p>\n\n\n\n<p>We have also changed the&nbsp;<em>historicalData<\/em>&nbsp;Ewrapper&nbsp;function and instead of printing out the bar information, we are using each returned bar\u2019s data to create a python dictionary and then append that to the&nbsp;<em>hist_data<\/em>&nbsp;class variable. I would like to clarify here that appending dictionaries to a dataframe is not the most efficient way of handling&nbsp;dataframes and that the TWS API has provisions to achieve the same thing more efficiently. However, I have kept that out of scope of this article.&nbsp;<\/p>\n\n\n\n<p><strong>Creating Option Contract<\/strong>&nbsp;<\/p>\n\n\n\n<p>Option contracts have a number of properties which are required to identify the exact option contract. In addition to the symbol of the underlying stock, exchange, currency and expiry data we also need to know the strike price of the option and whether the option is a Call or a Put. Therefore, you may have figured out already that we will have to change how we define the parameters of the contract object. Refer the below code for&nbsp;the option contract that I have used in this demo.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"371\" height=\"120\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-2.png\" alt=\"\" class=\"wp-image-117521 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-2.png 371w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-2-300x97.png 300w\" data-sizes=\"(max-width: 371px) 100vw, 371px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 371px; aspect-ratio: 371\/120;\" \/><\/figure>\n\n\n\n<p>In the above code, I have created the contract object for the call option on Amazon\u2019s stock having a strike price of 3400 and expiry date of 31<sup>st<\/sup>&nbsp;December 2021 (which is a week from when I am writing this article). You can also see that I have defined the exchange as BOX which should work for most US listed option contracts.&nbsp;&nbsp;<\/p>\n\n\n\n<p>It should be noted that if we define the option contract parameters loosely then TWS will return details for a number of option contracts. For example, if we do not define the strike parameter or define the&nbsp;<em>lastTradeDateorContractMonth<\/em>&nbsp;as \u201c202201\u201d&nbsp;(i.e. only the year and month)&nbsp;then we will get a number of option contracts satisfying&nbsp;the defined parameters. Therefore, please ensure that you are defining all the relevant parameters which will help TWS pin point the exact option that you are interested in.&nbsp;<\/p>\n\n\n\n<p><strong>Storing Historical Data<\/strong>&nbsp;<\/p>\n\n\n\n<p>Finally let us execute the&nbsp;<em>reqHistoricalData<\/em>&nbsp;function of our Trading Application to extract historical data for the required option contract.&nbsp;TWS&nbsp;will then&nbsp;send us data through the&nbsp;<em>historicalData<\/em>&nbsp;EWrapper&nbsp;function where we are updating the&nbsp;<em>hist_data&nbsp;<\/em>class variable.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"364\" height=\"185\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-3.png\" alt=\"\" class=\"wp-image-117528 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-3.png 364w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-3-300x152.png 300w\" data-sizes=\"(max-width: 364px) 100vw, 364px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 364px; aspect-ratio: 364\/185;\" \/><\/figure>\n\n\n\n<p>There may be some lag between when the function is executed and when the entire data is received and therefore I am adding a 5 second delay before printing out the class variable&nbsp;<em>hist_data<\/em>.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"456\" height=\"207\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-4.png\" alt=\"\" class=\"wp-image-117535 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-4.png 456w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-4-300x136.png 300w\" data-sizes=\"(max-width: 456px) 100vw, 456px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 456px; aspect-ratio: 456\/207;\" \/><\/figure>\n\n\n\n<p><strong>Historical Data of Expired Option Contracts<\/strong>&nbsp;<\/p>\n\n\n\n<p><em>Before we commence&nbsp;our discussion on this topic&nbsp;please note that&nbsp;the date as of writing of this article&nbsp;is&nbsp;24<\/em><em><sup>th<\/sup><\/em><em>&nbsp;December 2021. You will need to keep this date in mind and consider the dates presented below in reference to this date.&nbsp;<\/em>&nbsp;<\/p>\n\n\n\n<p>Unlike future contracts,&nbsp;where we could use&nbsp;the parameter&nbsp;<em>includeExpired&nbsp;<\/em>to get historical data for expired futures<em>,&nbsp;<\/em>there is&nbsp;no such provision&nbsp;for expired option contracts.&nbsp;Therefore,&nbsp;we will have to use a hack&nbsp;which will get us reasonably good historical data for expired options. This hack is based on the Black Scholes Formula which calculates option price based on:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Underlying stock price&nbsp;&nbsp;<\/li><li>Volatility&nbsp;<\/li><li>Strike price&nbsp;<\/li><li>Time to maturity&nbsp;&nbsp;<\/li><li>Interest rate&nbsp;&nbsp;<\/li><\/ul>\n\n\n\n<p>If we have access to these five pieces of information for an expired option, we should be able to derive the option price at any point in the past by feeding this information into the Black Scholes Option Pricing Model.&nbsp;For example, let\u2019s&nbsp;take the expired call option on Amazon\u2019s stock&nbsp;having&nbsp;strike&nbsp;price&nbsp;of 3380 which expired on 1<sup>st<\/sup>&nbsp;October 2021.&nbsp;I want to find the price of&nbsp;this&nbsp;expired option&nbsp;as of&nbsp;1<sup>st<\/sup>&nbsp;August&nbsp;2021. To calculate the&nbsp;option&nbsp;price,&nbsp;I&nbsp;would need&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The price of Amazon stock&nbsp;on&nbsp;1<sup>st<\/sup>&nbsp;August 2021&nbsp;&nbsp;<\/li><\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>The implied volatility of Amazon\u2019s stock&nbsp;on&nbsp;1<sup>st<\/sup>&nbsp;August 2021&nbsp;<\/li><\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>The strike price which we already know (3380)&nbsp;<\/li><\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\"><li>Time to expiry which is 61&nbsp;days&nbsp;(time from 1<sup>st<\/sup>&nbsp;August to 1<sup>st<\/sup>&nbsp;October) or 61\/365 years&nbsp;<\/li><\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\"><li>Interest rate which is usually taken as the long term yield on government debt. Let us take 3% for this demo based on long term treasury yield&nbsp;<\/li><\/ol>\n\n\n\n<p>Since we already have the last three&nbsp;pieces of information&nbsp;(strike, time to expiry and interest rate), all that we need is the historical price and the historical implied volatility of&nbsp;the stock&nbsp;to calculate the option price as of 1<sup>st<\/sup>&nbsp;August 2021.&nbsp;<\/p>\n\n\n\n<p>Deriving the Black Scholes formula is out of scope&nbsp;for&nbsp;this article but I strongly recommend that you gain some familiarity with this very popular formula. Below is the python code which implements the Black Scholes model.&nbsp;We will need to import the Numpy and&nbsp;Scipy.stats&nbsp;libraries to be able to get this function to work.&nbsp;&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"644\" height=\"187\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-5.png\" alt=\"\" class=\"wp-image-117542 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-5.png 644w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-5-300x87.png 300w\" data-sizes=\"(max-width: 644px) 100vw, 644px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 644px; aspect-ratio: 644\/187;\" \/><\/figure>\n\n\n\n<p>I hope you have realized where I am going with this.&nbsp;In order to use the magic of the above function, all&nbsp;that we need to do is&nbsp;request historical data&nbsp;and implied volatility data for Amazon which is quite straight forward.&nbsp;<\/p>\n\n\n\n<p>Now that we have an&nbsp;intuitive understanding&nbsp;of&nbsp;this approach, let us go about building our trading application.&nbsp;<\/p>\n\n\n\n<p><strong>Trading Application&nbsp;2.0<\/strong>&nbsp;<\/p>\n\n\n\n<p>This time around, we will need two class variables for our&nbsp;TradeApp&nbsp;class. One to store stock data and other to store implied volatility data. In addition, we also need to find a way to segregate the information provided by TWS in the relevant class variables. Thankfully, this could be easily achieved by manipulating the&nbsp;<em>reqId<\/em>&nbsp;because we will have to have different&nbsp;<em>requestIds<\/em>&nbsp;for our request for stock data and implied volatility data. Refer below screenshot of the trading application code.&nbsp;&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"618\" height=\"352\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-6.png\" alt=\"\" class=\"wp-image-117549 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-6.png 618w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-6-300x171.png 300w\" data-sizes=\"(max-width: 618px) 100vw, 618px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 618px; aspect-ratio: 618\/352;\" \/><\/figure>\n\n\n\n<p>We are asking our trading application to store the received data to the&nbsp;<em>hist_data<\/em>&nbsp;variable if the&nbsp;<em>reqId<\/em>&nbsp;is 0 else store it in the&nbsp;<em>impvol_data<\/em>&nbsp;variable. Therefore, when we are firing off the&nbsp;app.reqHistoricalData()&nbsp;request, we should be mindful of what&nbsp;reqId&nbsp;to pass as parameters for this trading application to work as desired.&nbsp;<\/p>\n\n\n\n<p><strong>Creating Contract and Requesting Data<\/strong>&nbsp;<\/p>\n\n\n\n<p>The contract object this time around is not going to be an option contract but a simple stock contract of the underlying stock. That is because we plan on using the data of this stock to derive the price of the option.&nbsp;I want to extract daily data for the past 300 days.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"483\" height=\"425\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-7.png\" alt=\"\" class=\"wp-image-117557 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-7.png 483w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-7-300x264.png 300w\" data-sizes=\"(max-width: 483px) 100vw, 483px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 483px; aspect-ratio: 483\/425;\" \/><\/figure>\n\n\n\n<p>We will have to request the historical&nbsp;price&nbsp;of the&nbsp;stock and&nbsp;historical&nbsp;implied volatility&nbsp;of the stock&nbsp;separately. For implied volatility, we will have to change the&nbsp;<em>whatToShow<\/em>&nbsp;parameter to OPTION_IMPLIED_VOLATILITY as per the TWS API historical data documentation&nbsp;<a href=\"https:\/\/interactivebrokers.github.io\/tws-api\/historical_bars.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/interactivebrokers.github.io\/tws-api\/historical_bars.html<\/a>&nbsp;<\/p>\n\n\n\n<p>As discussed above, we will have to use different&nbsp;<em>reqId<\/em>&nbsp;for the two requests and ensure that the&nbsp;<em>reqId<\/em>&nbsp;is consistent with our logic in the&nbsp;<em>historicalData<\/em>&nbsp;EWrapper&nbsp;function. We will have to add some time delay after each request as extracting historical data can take some time. There is a smarter way to get around this issue of adding delay after each request but that topic is for a later date.&nbsp;<\/p>\n\n\n\n<p><strong>Preparing&nbsp;Data&nbsp;to Feed the Black Scholes Model<\/strong>&nbsp;<\/p>\n\n\n\n<p>We now have everything that we need. All that is required now is to prepare the data so that the Black Scholes function can process it seamlessly.&nbsp;I prefer to create copies of the class variables into&nbsp;local variables but you may directly use the class variables. It is also a good idea to make the Date column as the index of both the dataframes.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"710\" height=\"371\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-8.png\" alt=\"\" class=\"wp-image-117564 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-8.png 710w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-8-700x366.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-8-300x157.png 300w\" data-sizes=\"(max-width: 710px) 100vw, 710px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 710px; aspect-ratio: 710\/371;\" \/><\/figure>\n\n\n\n<p>In the above code snippet, you can see that I have created a&nbsp;<em>dayCount<\/em>&nbsp;function. This is a utility function which will simply calculate the time to maturity of the option on each day. This is required because time to maturity is one of the requirements of the Black Scholes model. Refer below screenshot which shows how this function transforms the dataframe by adding the maturity column to the dataframe. Please note that maturity is in years, i.e. time to maturity&nbsp;for this option contract&nbsp;as of&nbsp;24th&nbsp;September 2021 was 7 days which translates to 7\/365 or 0.019178 years.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"387\" height=\"232\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-9.png\" alt=\"\" class=\"wp-image-117571 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-9.png 387w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-9-300x180.png 300w\" data-sizes=\"(max-width: 387px) 100vw, 387px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 387px; aspect-ratio: 387\/232;\" \/><\/figure>\n\n\n\n<p><strong>Calculating Historical Price for Expired Options<\/strong>&nbsp;<\/p>\n\n\n\n<p>Now all that needs to be done is passing the prepared data to the Black Scholes function. Refer below code snippet.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"526\" height=\"171\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-10.png\" alt=\"\" class=\"wp-image-117578 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-10.png 526w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-10-300x98.png 300w\" data-sizes=\"(max-width: 526px) 100vw, 526px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 526px; aspect-ratio: 526\/171;\" \/><\/figure>\n\n\n\n<p>I have created an empty dataframe called&nbsp;<em>option_price&nbsp;<\/em>which will store the option prices calculated by our model.&nbsp;I have removed all bars which happened after the maturity date because there is no option price to be calculated once the option expires.&nbsp;<\/p>\n\n\n\n<p>We will iterate through each column of our dataframes (open, high, low and close) and calculate&nbsp;option price pertaining to that column. An important thing to note here is that for Open and Close columns, we should get the exact option price since the opening and closing prices of the stock should correspond to the opening and closing&nbsp;implied&nbsp;volatility. However, there is no guarantee that the high and low stock price correspond&nbsp;to&nbsp;the high and low implied volatility. Therefore, let me state the rider here that the high and low prices calculated will not be very accurate. Being mindful of the limitation, let us run the above lines of codes and see what we get.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"322\" height=\"233\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-11.png\" alt=\"\" class=\"wp-image-117585 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-11.png 322w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-11-300x217.png 300w\" data-sizes=\"(max-width: 322px) 100vw, 322px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 322px; aspect-ratio: 322\/233;\" \/><\/figure>\n\n\n\n<p>So we have got the open, high, low and close prices of the expired option.&nbsp;But are these prices any good? Thankfully, I had taken the screenshot of Amazon\u2019s option chain on 22<sup>nd<\/sup>&nbsp;September 2021 few minutes before the market closed. Refer below screenshot.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-12.png\" alt=\"\" class=\"wp-image-117592 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>You can see that the bid and ask prices for the call option contract expiring on 1<sup>st<\/sup>&nbsp;October 2021 having strike price of 3380 (i.e. same expired option that we considered in this demo) were 47.55 and 48.55 respectively. Now what price have we calculated?&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"286\" height=\"110\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/12\/Historical-Options-Futures-Data-using-TWS-API-Part2-13.png\" alt=\"\" class=\"wp-image-117598 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 286px; aspect-ratio: 286\/110;\"><\/figure>\n\n\n\n<p>From the above, you can see that the close price calculated by us is 48.02 which looks pretty good. I encourage you to test this implementation on other&nbsp;option contracts&nbsp;and drop me a note if you find something interesting or come across&nbsp;any discrepancy.&nbsp;<\/p>\n\n\n\n<p>The author can be reached at&nbsp;<strong>contact@rasuquant.com<\/strong>&nbsp;<\/p>\n\n\n\n<p>If you found this article interesting, you may&nbsp;consider enrolling in&nbsp;my&nbsp;Interactive Brokers API centric courses on&nbsp;<a href=\"https:\/\/learning.rasuquant.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/learning.rasuquant.com<\/a>.&nbsp;The courses range from&nbsp;basics of TWS API&nbsp;to advanced concepts that will&nbsp;help you&nbsp;backtest and&nbsp;build fully automated trading applications on Interactive Brokers\u2019&nbsp;platform.&nbsp;&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will now see how we can extract historical data for options contracts. We will first cover the easy part which is getting data for live option contracts.<\/p>\n","protected":false},"author":565,"featured_media":117695,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[340,343,349,338,350,341,351,352,9563,2197],"tags":[10867,1014,1015,865,5110,575,1225,1224,595,10877],"contributors-categories":[13715],"class_list":{"0":"post-117502","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-europe","14":"category-quant-north-america","15":"category-options-quant","16":"category-quant-south-america","17":"tag-black-scholes-model","18":"tag-eclient","19":"tag-ewrapper","20":"tag-github","21":"tag-historical-data","22":"tag-ibkr-api","23":"tag-numpy","24":"tag-pandas","25":"tag-python","26":"tag-scipy-stats-library","27":"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>Historical Options &#038; Futures Data using TWS API \u2013 Part II<\/title>\n<meta name=\"description\" content=\"We will now see how we can extract historical data for options contracts. We will first cover the easy part which is getting data for live option...\" \/>\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\/117502\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Historical Options &amp; Futures Data using TWS API \u2013 Part II | IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"We will now see how we can extract historical data for options contracts. We will first cover the easy part which is getting data for live option contracts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-03T17:09:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-21T14:50:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/01\/swirls.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\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=\"11 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\\\/historical-options-futures-data-using-tws-api-part-ii\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/historical-options-futures-data-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\": \"Historical Options &#038; Futures Data using TWS API \u2013 Part II\",\n\t            \"datePublished\": \"2022-01-03T17:09:00+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:50:30+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/historical-options-futures-data-using-tws-api-part-ii\\\/\"\n\t            },\n\t            \"wordCount\": 2237,\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\\\/historical-options-futures-data-using-tws-api-part-ii\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/01\\\/swirls.jpg\",\n\t            \"keywords\": [\n\t                \"Black Scholes Model\",\n\t                \"EClient\",\n\t                \"EWrapper\",\n\t                \"GitHub\",\n\t                \"historical data\",\n\t                \"IBKR API\",\n\t                \"NumPy\",\n\t                \"Pandas\",\n\t                \"Python\",\n\t                \"Scipy.stats library\"\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 Europe\",\n\t                \"Quant North America\",\n\t                \"Quant Options\",\n\t                \"Quant South America\"\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\\\/historical-options-futures-data-using-tws-api-part-ii\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/historical-options-futures-data-using-tws-api-part-ii\\\/\",\n\t            \"name\": \"Historical Options & Futures Data 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\\\/historical-options-futures-data-using-tws-api-part-ii\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/historical-options-futures-data-using-tws-api-part-ii\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/01\\\/swirls.jpg\",\n\t            \"datePublished\": \"2022-01-03T17:09:00+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:50:30+00:00\",\n\t            \"description\": \"We will now see how we can extract historical data for options contracts. We will first cover the easy part which is getting data for live option contracts.\",\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\\\/historical-options-futures-data-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\\\/historical-options-futures-data-using-tws-api-part-ii\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/01\\\/swirls.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/01\\\/swirls.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\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":"Historical Options &#038; Futures Data using TWS API \u2013 Part II","description":"We will now see how we can extract historical data for options contracts. We will first cover the easy part which is getting data for live option...","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\/117502\/","og_locale":"en_US","og_type":"article","og_title":"Historical Options & Futures Data using TWS API \u2013 Part II | IBKR Quant Blog","og_description":"We will now see how we can extract historical data for options contracts. We will first cover the easy part which is getting data for live option contracts.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/","og_site_name":"IBKR Campus US","article_published_time":"2022-01-03T17:09:00+00:00","article_modified_time":"2022-11-21T14:50:30+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/01\/swirls.jpg","type":"image\/jpeg"}],"author":"Mayank Rasu","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mayank Rasu","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/"},"author":{"name":"Mayank Rasu","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/41a7b1d2d6971906a0d461646888e9fc"},"headline":"Historical Options &#038; Futures Data using TWS API \u2013 Part II","datePublished":"2022-01-03T17:09:00+00:00","dateModified":"2022-11-21T14:50:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/"},"wordCount":2237,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/01\/swirls.jpg","keywords":["Black Scholes Model","EClient","EWrapper","GitHub","historical data","IBKR API","NumPy","Pandas","Python","Scipy.stats library"],"articleSection":["IBKR API Development","Programming Languages","Python Development","Quant","Quant Asia Pacific","Quant Development","Quant Europe","Quant North America","Quant Options","Quant South America"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/","name":"Historical Options & Futures Data 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\/historical-options-futures-data-using-tws-api-part-ii\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/01\/swirls.jpg","datePublished":"2022-01-03T17:09:00+00:00","dateModified":"2022-11-21T14:50:30+00:00","description":"We will now see how we can extract historical data for options contracts. We will first cover the easy part which is getting data for live option contracts.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/historical-options-futures-data-using-tws-api-part-ii\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/01\/swirls.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/01\/swirls.jpg","width":1000,"height":563,"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\/2022\/01\/swirls.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/117502","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=117502"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/117502\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/117695"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=117502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=117502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=117502"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=117502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}