{"id":217858,"date":"2025-01-28T11:41:09","date_gmt":"2025-01-28T16:41:09","guid":{"rendered":"https:\/\/ibkrcampus.com\/campus\/?p=217858"},"modified":"2025-01-28T11:41:45","modified_gmt":"2025-01-28T16:41:45","slug":"expected-shortfall-es","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/","title":{"rendered":"Expected Shortfall (ES)"},"content":{"rendered":"\n<p><em>The article \u201cExpected Shortfall (ES)\u201d was originally posted on <a href=\"https:\/\/blog.quantinsti.com\/cvar-expected-shortfall\/\">QuantInsti<\/a> blog.<\/em><\/p>\n\n\n\n<p>If you are reading this blog, this means that you are aware of Value at Risk, or simply VaR which is the largest loss that can be incurred by a portfolio with a given confidence level (i.e. a pre-specified probability level).<\/p>\n\n\n\n<p>However, there is a significant drawback which the VaR as a risk measure carries. In particular, it tells us the threshold of potential loss but not how bad the loss can be beyond that threshold.<\/p>\n\n\n\n<p>For example, if a portfolio\u2019s 1-day VaR is $1 million at a 95% confidence level, you don\u2019t know how much the loss could be in the remaining 5% of the cases. In addition, it does not account for \u201ctail risk&#8221; or extreme events that may lead to larger losses. This brings us to yet another statistical risk measure called Expected Shortfall (ES), which fixes this problem to some extent.<\/p>\n\n\n\n<p>As seen in the preceding paragraph, to be fully equipped to understand the topic of Expected Shortfall, first one needs to have the knowledge of VaR. What follows is the list of prerequisites needed alongside their descriptions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"prerequisites\">Prerequisites<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The introduction to VaR is explained&nbsp;<a href=\"https:\/\/blog.quantinsti.com\/value-at-risk\/\">here<\/a>. By reading the referred blog, you will learn how to compute and interpret portfolio VaR, its limitations and advantages in simplest and shortest possible way.<\/li>\n\n\n\n<li>To get a comprehensive knowledge about VaR and related topics, you can refer to the blog \u201cValue at Risk\u201d. Here you will find a detailed explanation of VaR, its computation in various ways. In addition, this blog provides a coverage of topics like Marginal VaR, Incremental VaR and Component VaR. In short, these VaR tools measure the effects of changing portfolio positions on existing portfolio VaR.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-expected-shortfall-es\">What is Expected Shortfall (ES)<\/h2>\n\n\n\n<p>Simply put, Expected Shortfall is the average loss beyond VaR. It measures the expected loss in the tail of a distribution beyond a certain quantile level (e.g., 95%). It provides insight into the potential losses exceeding the Value at Risk (VaR). Obviously, we specify the confidence level by which ES is computed. Below is the geometric illustration of ES alongside with VaR. Here are the steps for the computation of ES:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"720\" height=\"535\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-1-quantinsti.png\" alt=\"\" class=\"wp-image-217860 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-1-quantinsti.png 720w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-1-quantinsti-700x520.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-1-quantinsti-300x223.png 300w\" data-sizes=\"(max-width: 720px) 100vw, 720px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 720px; aspect-ratio: 720\/535;\" \/><\/figure>\n\n\n\n<p><strong>1. Define Parameters<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Confidence Level (c):<\/strong>&nbsp;Choose the confidence level, typically 95% or 99%.<\/li>\n\n\n\n<li><strong>Loss Distribution:<\/strong>&nbsp;Have the historical or simulated distribution of portfolio returns or losses.<\/li>\n\n\n\n<li><strong>Calculate portfolio value at risk (VaRp):<\/strong>\u00a0This is also computed by the same confidence level.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1100\" height=\"138\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-1-1100x138.jpg\" alt=\"\" class=\"wp-image-217862 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-1-1100x138.jpg 1100w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-1-700x88.jpg 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-1-300x38.jpg 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-1-768x96.jpg 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-1.jpg 1389w\" data-sizes=\"(max-width: 1100px) 100vw, 1100px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1100px; aspect-ratio: 1100\/138;\" \/><\/figure>\n\n\n\n<p>where z stands for standard normal quantile corresponding to c probability, p is the standard deviation of portfolio returns and W represents the portfolio value in dollars.<\/p>\n\n\n\n<p><strong>2.&nbsp;Calculate Expected Loss Beyond (VaR):&nbsp;<\/strong>This is in effect the Expected Shortfall and is computed by the formula<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1100\" height=\"84\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-2-1100x84.jpg\" alt=\"\" class=\"wp-image-217863 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-2-1100x84.jpg 1100w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-2-700x54.jpg 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-2-300x23.jpg 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-2-768x59.jpg 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-2.jpg 1393w\" data-sizes=\"(max-width: 1100px) 100vw, 1100px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1100px; aspect-ratio: 1100\/84;\" \/><\/figure>\n\n\n\n<p>where&nbsp;LL&nbsp;denotes the loss as a random variable (i.e. the possible value of actual loss). The above formula is read as the expected (average) loss given that this loss is greater than&nbsp;VaRp.<\/p>\n\n\n\n<p>The formula of Expected Shortfall is a theoretical one. We take empirical (historical data based) and analytic approaches to compute this quantity.<\/p>\n\n\n\n<p><strong>Empirical Approach:<\/strong><\/p>\n\n\n\n<p>The simplest way to compute the ES from historical data is to find VaR using the non-parametric method. As long as VaR is computed, one needs to simply average out all historically observed values beyond this quantity.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p>We extend the example given in the section \u201cNon-Parametric VaR\u201d of blog Value at Risk. In particular, as long as the annual VaR (in this case we use VaR (zero), however VaR (mean) would also work) has been computed, we compute the average value of losses beyond this level. Note that these quantities are computed in the blog on the given link above. See the attached Excel file for full computations as well.<\/p>\n\n\n\n<p>The given portfolio in this example is initially worth $1,000,000 and it consists of three assets. First, the portfolio values are computed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"318\" height=\"228\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-2-quantinsti.png\" alt=\"\" class=\"wp-image-217865 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-2-quantinsti.png 318w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-2-quantinsti-300x215.png 300w\" data-sizes=\"(max-width: 318px) 100vw, 318px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 318px; aspect-ratio: 318\/228;\" \/><\/figure>\n\n\n\n<p>Then we compute the loss incurred compared to the initial value of the portfolio.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"700\" height=\"520\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-3.gif\" alt=\"\" class=\"wp-image-217867 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 700px; aspect-ratio: 700\/520;\" \/><\/figure>\n\n\n\n<p>The VaR turns out to be $326,554.42 (computed in the blog above) while the Expected Shortfall is $337,559.84. This quantity is computed by (2) as illustrated below<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"700\" height=\"520\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-4.gif\" alt=\"\" class=\"wp-image-217868 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 700px; aspect-ratio: 700\/520;\" \/><\/figure>\n\n\n\n<p>We interpret this quantity as the expected loss in extreme circumstances. To make it clearer and simpler, $337,559.84 is the expected amount if the actual loss surpasses $326,554.42 (the VaR). This is a self-explanatory number in the sense that it provides an impression about what to expect in extreme cases, i.e. if the 5% probability of loss exceeding VaR is realised.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import numpy as np\nimport pandas as pd\nimport yfinance as yf\nfrom scipy.stats import norm\n\n# Download the data\namzn = yf.download('AMZN', '2023-11-30', '2024-11-30')\ntsla = yf.download('TSLA', '2023-11-30', '2024-11-30')\naapl = yf.download('AAPL', '2023-11-30', '2024-11-30')\n\n# Extract only closing prices\namzn_close = amzn['Close']\ntsla_close = tsla['Close']\naapl_close = aapl['Close']\n\n# Put all three closing prices together\ndf = pd.concat([amzn_close, tsla_close, aapl_close], axis=1)\ndf.columns = ['AMZN', 'TSLA', 'AAPL']\n\n# Compute the returns\ndf['R1'] = -df['AMZN'].pct_change()\ndf['R2'] = -df['TSLA'].pct_change()\ndf['R3'] = -df['AAPL'].pct_change()\n\n# Construct the portfolio returns column as a weighted sum of individual asset returns and weights\nw = np.array([0.4, 0.3, 0.3])\ndf['Rp'] = (df[['R1', 'R2', 'R3']] * w).sum(axis=1)\ndf = df.drop(df.index[0])\n\n# Add the Portfolio column with an initial value of 1,000,000\nW = 1000000\ndf['Portfolio'] = W * (1 + df['Rp']).cumprod()\n\n# Compute losses and add as a column to df\ndf['L'] = W - df['Portfolio']\n\n# Compute VaR(zero)\nVaR_zero = W - df['Portfolio'].quantile(0.05)\n\n# Expected Shortfall\nES = df.loc[df['L'] &gt; VaR_zero, 'L'].mean()\n\nprint('Expected Shortfall is: {:.2f}'.format(ES))<\/pre>\n\n\n\n<p><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/968b2acecc7d61503e96c017fc83832f#file-expected_shortfall-py\" target=\"_blank\" rel=\"noreferrer noopener\">Expected_shortfall.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a><\/p>\n\n\n\n<p><strong>Analytic Approach:<\/strong><\/p>\n\n\n\n<p>Instead of computing ES by non-parametric method, as long as the parameters of loss distribution are estimated, we can compute it via the analytic method. In particular, the ES given by (2) is equivalent to<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1100\" height=\"110\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-5-1100x110.jpg\" alt=\"\" class=\"wp-image-217870 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-5-1100x110.jpg 1100w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-5-700x70.jpg 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-5-300x30.jpg 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-5-768x77.jpg 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-5.jpg 1417w\" data-sizes=\"(max-width: 1100px) 100vw, 1100px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1100px; aspect-ratio: 1100\/110;\" \/><\/figure>\n\n\n\n<p>where\u00a0<em>l<\/em>\u00a0denotes the loss. So this formula just gives the average of the losses beyond\u00a0<em>VaRp<\/em>\u00a0adjusted to the confidence level\u00a0cc. If the distribution is known, the computation becomes simpler. In the simplest case, assuming the losses are normally distributed (which is quite a basic assumption, not necessarily true though), we compute the ES by the following formula:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1100\" height=\"91\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-6-1100x91.jpg\" alt=\"\" class=\"wp-image-217871 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-6-1100x91.jpg 1100w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-6-700x58.jpg 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-6-300x25.jpg 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-6-768x64.jpg 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-6.jpg 1435w\" data-sizes=\"(max-width: 1100px) 100vw, 1100px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1100px; aspect-ratio: 1100\/91;\" \/><\/figure>\n\n\n\n<p>where L and L denote the mean and standard deviation of losses respectively. Note that these quantities have the indexes to differentiate them from portfolio return mean and standard deviation. z usually represents the standard normal quantile corresponding to c confidence level and &nbsp;is the standard normal density function. (Would be great to have a link for probability distributions). The computations are given in the example below<\/p>\n\n\n\n<p><strong>Example cont\u2019d:<\/strong><\/p>\n\n\n\n<p>Now we compute the ES using the analytic, a.k.a. parametric method. Estimated mean and standard deviations are respectively.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1100\" height=\"110\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-8-quantinsti-1100x110.png\" alt=\"\" class=\"wp-image-217875 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-8-quantinsti-1100x110.png 1100w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-8-quantinsti-700x70.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-8-quantinsti-300x30.png 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-8-quantinsti-768x77.png 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/Normal-distribution-8-quantinsti.png 1282w\" data-sizes=\"(max-width: 1100px) 100vw, 1100px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1100px; aspect-ratio: 1100\/110;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"700\" height=\"320\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-7.gif\" alt=\"\" class=\"wp-image-217877 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 700px; aspect-ratio: 700\/320;\" \/><\/figure>\n\n\n\n<p>we can compute ES by (4) to be $328,130.07.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"700\" height=\"470\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/01\/quantinsti-expected-shortfall-formula-9.gif\" alt=\"\" class=\"wp-image-217878 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 700px; aspect-ratio: 700\/470;\" \/><\/figure>\n\n\n\n<p>Note that this quantity is slightly lower than the ES value computed by non-parametric method, however both certainly are greater than VaR.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import numpy as np\nimport pandas as pd\nimport yfinance as yf\nfrom scipy.stats import norm\n\n# Download the data\namzn = yf.download('AMZN', '2023-11-30', '2024-11-30')\ntsla = yf.download('TSLA', '2023-11-30', '2024-11-30')\naapl = yf.download('AAPL', '2023-11-30', '2024-11-30')\n\n# Extract only closing prices\namzn_close = amzn['Close']\ntsla_close = tsla['Close']\naapl_close = aapl['Close']\n\n# Put all three closing prices together\ndf = pd.concat([amzn_close, tsla_close, aapl_close], axis=1)\ndf.columns = ['AMZN', 'TSLA', 'AAPL']\n\n# Compute the returns\ndf['R1'] = -df['AMZN'].pct_change()\ndf['R2'] = -df['TSLA'].pct_change()\ndf['R3'] = -df['AAPL'].pct_change()\n\n# Construct the portfolio returns column as a weighted sum of individual asset returns and weights\nw = np.array([0.4, 0.3, 0.3])\ndf['Rp'] = (df[['R1', 'R2', 'R3']] * w).sum(axis=1)\ndf = df.drop(df.index[0])\n\n# Add the Portfolio column with an initial value of 1,000,000\nW = 1000000\ndf['Portfolio'] = W * (1 + df['Rp']).cumprod()\n\n# Compute losses and add as a column to df\ndf['L'] = W - df['Portfolio']\n\n# Compute VaR(zero)\nVaR_zero = W - df['Portfolio'].quantile(0.05)\n\n# Expected Shortfall\n# ES = df.loc[df['L'] &gt; VaR_zero, 'L'].mean()\n# print('Expected Shortfall is: {:.2f}'.format(ES))\n\nES_analytic = df['L'].mean() + df['L'].std() * norm.pdf(norm.ppf(0.95)) \/ (1 - 0.95)\nprint('Expected Shortfall is: {:.2f}'.format(ES_analytic))<\/pre>\n\n\n\n<p><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/b3f5004cb17d6afcb225b1f009bf9745#file-expected_shortfall_es_analytic-py\" target=\"_blank\" rel=\"noreferrer noopener\">Expected_shortfall_ES_analytic.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a><\/p>\n\n\n\n<p><strong>Pros of using Expected Shortfall as a risk measure:<\/strong><\/p>\n\n\n\n<p><strong>1. Accounts for Tail Risk<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unlike Value at Risk (VaR), which only considers the threshold loss at a given confidence level, ES averages all losses beyond the VaR, providing a more comprehensive view of tail risk.<\/li>\n<\/ul>\n\n\n\n<p><strong>\u00a0<\/strong><strong>2.&nbsp;Better risk sensitivity<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unlike Value at Risk (VaR), which only considers the threshold loss at a given confidence level, ES averages all losses beyond the VaR, providing a more comprehensive view of tail risk.<\/li>\n<\/ul>\n\n\n\n<p><strong>3. Regulatory Acceptance<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ES is increasingly used in financial regulations (e.g., Basel III) because it overcomes some of VaR\u2019s limitations, such as ignoring losses beyond the VaR threshold.<\/li>\n<\/ul>\n\n\n\n<p><strong>4. Flexibility<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ES can be applied to various distributions and risk scenarios, including heavy-tailed distributions and non-normal data.<\/li>\n<\/ul>\n\n\n\n<p><em><strong>Cons and Limitations of using&nbsp;<\/strong><\/em><strong>Expected Shortfall<em>&nbsp;<\/em><\/strong><em><strong>as a risk measure:<\/strong><\/em><\/p>\n\n\n\n<p><strong>1. Estimation challenges<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ES requires accurate modeling of the tail of the loss distribution, which is difficult in practice due to the scarcity of extreme loss data.<\/li>\n<\/ul>\n\n\n\n<p><strong>2.&nbsp;Data and dependence<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Historical and simulation-based methods can produce inaccurate ES estimates if the data does not adequately capture future risk scenarios.<\/li>\n<\/ul>\n\n\n\n<p><strong>3.&nbsp;Computational intensity<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calculating ES can be computationally demanding, especially for complex portfolios or when using Monte Carlo simulation.<\/li>\n<\/ul>\n\n\n\n<p><strong>4.&nbsp;Interpretation complexity<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The choice of the confidence level (c) significantly affects ES, introducing a degree of subjectivity.<\/li>\n<\/ul>\n\n\n\n<p><strong>5.&nbsp;Sensitivity to model assumptions<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The accuracy of ES depends heavily on the assumed distribution of losses. Mis-specification of the distribution can lead to unreliable estimates.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h3>\n\n\n\n<p>This blog covered an interesting quantity \u2013 Expected Shortfall (ES). ES is the expected loss surpassing the VaR level. It gives a valuable information in the sense that during the realization of extreme losses, one knows what to expect on average. VaR as a risk measure, fails to account for this loss. There are several ways to compute Expected Shortfall. Examples were given illustrating computations of ES by non-parametric method, which gives an estimate using the historical data and an analytic method, which is more robust assuming the distribution of losses is known and the parameters of the distribution (like mean and standard deviation) estimated. Finally, the topic is summarized by providing the list of pros and cons of using ES as a risk measure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simply put, Expected Shortfall is the average loss beyond VaR.<\/p>\n","protected":false},"author":1569,"featured_media":191319,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[339,343,349,338,341],"tags":[806,865,1225,1224,595,4939,6674],"contributors-categories":[13654],"class_list":{"0":"post-217858","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-science","8":"category-programing-languages","9":"category-python-development","10":"category-ibkr-quant-news","11":"category-quant-development","12":"tag-data-science","13":"tag-github","14":"tag-numpy","15":"tag-pandas","16":"tag-python","17":"tag-statistics","18":"tag-yfinance","19":"contributors-categories-quantinsti"},"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.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Expected Shortfall (ES) | IBKR Quant<\/title>\n<meta name=\"description\" content=\"Simply put, Expected Shortfall is the average loss beyond VaR.\" \/>\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\/217858\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Expected Shortfall (ES)\" \/>\n<meta property=\"og:description\" content=\"Simply put, Expected Shortfall is the average loss beyond VaR.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-28T16:41:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-28T16:41:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.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=\"Tostne Kutalia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tostne Kutalia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 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:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Tostne Kutalia\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/8e21725efd5cbe8222eadd10ae8ef0a4\"\n\t            },\n\t            \"headline\": \"Expected Shortfall (ES)\",\n\t            \"datePublished\": \"2025-01-28T16:41:09+00:00\",\n\t            \"dateModified\": \"2025-01-28T16:41:45+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/\"\n\t            },\n\t            \"wordCount\": 1362,\n\t            \"commentCount\": 0,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/python-blue-background-digits.jpg\",\n\t            \"keywords\": [\n\t                \"Data Science\",\n\t                \"GitHub\",\n\t                \"NumPy\",\n\t                \"Pandas\",\n\t                \"Python\",\n\t                \"statistics\",\n\t                \"yfinance\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/\",\n\t            \"name\": \"Expected Shortfall (ES) | IBKR Campus US\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/python-blue-background-digits.jpg\",\n\t            \"datePublished\": \"2025-01-28T16:41:09+00:00\",\n\t            \"dateModified\": \"2025-01-28T16:41:45+00:00\",\n\t            \"description\": \"Simply put, Expected Shortfall is the average loss beyond VaR.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/expected-shortfall-es\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/python-blue-background-digits.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/python-blue-background-digits.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Python\"\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\\\/8e21725efd5cbe8222eadd10ae8ef0a4\",\n\t            \"name\": \"Tostne Kutalia\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/tostne1kutalia\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Expected Shortfall (ES) | IBKR Quant","description":"Simply put, Expected Shortfall is the average loss beyond VaR.","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\/217858\/","og_locale":"en_US","og_type":"article","og_title":"Expected Shortfall (ES)","og_description":"Simply put, Expected Shortfall is the average loss beyond VaR.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/","og_site_name":"IBKR Campus US","article_published_time":"2025-01-28T16:41:09+00:00","article_modified_time":"2025-01-28T16:41:45+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","type":"image\/jpeg"}],"author":"Tostne Kutalia","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tostne Kutalia","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/#article","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/"},"author":{"name":"Tostne Kutalia","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/8e21725efd5cbe8222eadd10ae8ef0a4"},"headline":"Expected Shortfall (ES)","datePublished":"2025-01-28T16:41:09+00:00","dateModified":"2025-01-28T16:41:45+00:00","mainEntityOfPage":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/"},"wordCount":1362,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","keywords":["Data Science","GitHub","NumPy","Pandas","Python","statistics","yfinance"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/","url":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/","name":"Expected Shortfall (ES) | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/#primaryimage"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","datePublished":"2025-01-28T16:41:09+00:00","dateModified":"2025-01-28T16:41:45+00:00","description":"Simply put, Expected Shortfall is the average loss beyond VaR.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/expected-shortfall-es\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","width":1000,"height":563,"caption":"Python"},{"@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\/8e21725efd5cbe8222eadd10ae8ef0a4","name":"Tostne Kutalia","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/tostne1kutalia\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/06\/python-blue-background-digits.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/217858","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\/1569"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=217858"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/217858\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/191319"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=217858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=217858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=217858"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=217858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}