{"id":184328,"date":"2023-01-27T14:32:00","date_gmt":"2023-01-27T19:32:00","guid":{"rendered":"https:\/\/ibkrcampus.com\/traders-insight\/value-at-risk-var-calculation-in-excel-and-python\/"},"modified":"2023-02-13T15:18:27","modified_gmt":"2023-02-13T20:18:27","slug":"value-at-risk-var-calculation-in-excel-and-python","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/","title":{"rendered":"Value at Risk (VaR) Calculation in Excel and Python"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">What is the most I can lose on an investment? This is the question every investor who has invested asks at some point in time. Value at Risk (VaR) tries to provide an answer since it is the measurement of the maximum expected loss a portfolio bears.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We will understand and perform VaR calculation in Excel and Python using the Historical Method and Variance-Covariance approach, along with examples with this blog that covers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What is VaR?<\/li>\n\n\n\n<li>Why use VaR?<\/li>\n\n\n\n<li>Essential points to know while using VaR<\/li>\n\n\n\n<li>How is VaR calculated in Excel?<\/li>\n\n\n\n<li>VaR calculation using Variance-Covariance approach<\/li>\n\n\n\n<li>VaR calculation using the Historical Simulation approach<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-var\">What is VaR?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Value at Risk or VaR is the measurement of the worst expected loss over a specified period under the usual market conditions. The VaR is measured using \u2018confidence levels\u2019 which lie in the range of 90% to 99% such as 90%, 95%, or 99%. The holding period of the financial instrument may vary from a day to a year.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In other words, VaR is a measure of market risk. It is the measure of maximum loss that can occur with a certain confidence interval over a given period of time. Using VaR, financial institutions can determine the sufficient capital reserves they need to cover losses. Also, VaR helps determine whether higher than acceptable risk holdings need to be reduced.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">According to Philippe Jorion,<br>\u201c<em>VaR measures the worst expected loss over a given horizon under normal market conditions at a given confidence level<\/em>\u201d.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, according to one of the studies&nbsp;<a href=\"https:\/\/lup.lub.lu.se\/luur\/download?func=downloadFile&amp;recordOId=1669008&amp;fileOId=2435920\" target=\"_blank\" rel=\"noreferrer noopener\">\u207d\u00b9\u207e<\/a>, it was concluded that \u200b\u200bVaR does not provide any certainty but rather expectation of outcomes based on certain assumptions.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example\">Example<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Lets us understand VaR with an example.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose, an analyst says that the 1-day VaR of a portfolio is 1 million dollars, with a 95% confidence level.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It implies there is a 95% chance that the maximum losses will not exceed 1 million dollars in a single day.<\/li>\n\n\n\n<li>In other words, there is only a 5% chance that the portfolio losses on a particular day will be greater than 1 million dollars. Learn&nbsp;<a href=\"https:\/\/quantra.quantinsti.com\/course\/quantitative-portfolio-management\" target=\"_blank\" rel=\"noreferrer noopener\">quantitative portfolio management<\/a>&nbsp;in detail in the Quantra course.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"why-use-var\">Why use VaR?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now, let us find out why one uses VaR or Value at Risk for measuring the expected loss. A trader utilises VaR for the following reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Understanding the Value at Risk result is easy<\/li>\n\n\n\n<li>Applicable to all asset types<\/li>\n\n\n\n<li>Universally utilised<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"understanding-the-result-of-value-at-risk-is-easy\">Understanding the result of Value at Risk is easy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Value at Risk represents the extent of risk a trader bears for investing in a portfolio in a single figure. For instance, the Value at Risk is between 90% and 99% which makes it easy to interpret the level of risk.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"applicable-to-all-asset-types\">Applicable to all asset types<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Vale at Risk can be easily applied to all asset types, namely, bonds, shares, currencies, derivatives, etc. Also, Value at Risk is utilised by all kinds of financial institutions and banks in order to assess the profitability over risk borne for trading a portfolio or asset. Learn&nbsp;<a href=\"https:\/\/quantra.quantinsti.com\/course\/financial-time-series-analysis-trading\" target=\"_blank\" rel=\"noreferrer noopener\">Financial Time Series Analysis for Trading<\/a>&nbsp;in detail in the Quantra course.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"universally-utilised\">Universally utilised<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Value at Risk is an accepted standard for basing buying, selling and all trade-related activities. Hence, you can use it anywhere across the globe.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"essential-points-to-know-while-using-var\">Essential points to know while using VaR<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">There are a couple of essential points that a trader must know while using VaR as the measurement of risk against investment in a portfolio or financial instrument. These points are:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. VaR is difficult to calculate for portfolios with a diversity of assets (such as cash, currency, stocks etc.) or a greater number of assets<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Calculating Value at Risk for a portfolio needs one to calculate the risk and return of each asset. But, along with the risk-return calculation, the correlations between the assets are also to be calculated. Hence, the more the number or diversity of assets in a portfolio, the more difficult it is to calculate VaR.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Different methods or approaches lead to varying results<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When different approaches to calculating VaR lead to different results for the same portfolio or the financial instrument, it implies the return distribution is not normal.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-is-var-calculated-in-excel\">How is VaR calculated in Excel?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">There are two well-known methods that are used for VaR calculation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this blog, we will discuss the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variance-covariance approach<\/li>\n\n\n\n<li>Historical simulation approach<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s start with the&nbsp;<strong>Variance-Covariance approach<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Variance-covariance is a parametric method which assumes that the returns are normally distributed. In this method,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We first calculate the mean and standard deviation of the returns<\/li>\n\n\n\n<li>According to the assumption, for &nbsp;95% confidence level, VaR is calculated as a mean -1.65 * standard deviation<\/li>\n\n\n\n<li>Also, as per the assumption, for 99% confidence level, VaR is calculated as mean -2.58 * standard deviation<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Please note that the abovementioned figures are on the basis of a subjective assumption&nbsp;<a href=\"https:\/\/stats.stackexchange.com\/questions\/580695\/why-confidence-level-95-is-1-65\" target=\"_blank\" rel=\"noreferrer noopener\">\u207d\u00b2\u207e<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Moving on, the steps for VaR calculation using the&nbsp;<strong>Historical simulation approach<\/strong>&nbsp;are as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Similar to the variance-covariance approach, first we calculate the returns of the stock Returns = Today\u2019s Price &#8211; Yesterday\u2019s Price \/ Yesterday\u2019s Price<\/li>\n\n\n\n<li>Sort the returns from worst to best.<\/li>\n\n\n\n<li>Next, we calculate the total count of the returns.<\/li>\n\n\n\n<li>The VaR(90) is the sorted return corresponding to 10% of the total count.<\/li>\n\n\n\n<li>Similarly, the VaR(95) and VaR(99) is the sorted return corresponding to the 5% and 1% of the total count respectively.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"var-calculation-using-variance-covariance-approach\">VaR calculation using Variance-Covariance approach<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we will find out the calculation if Variance-Covariance approach using Python.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># We will import the necessary libraries\n\nimport numpy as np\nimport pandas as pd\nimport yfinance as yf\nfrom tabulate import tabulate\n\n# Plotting\nimport matplotlib.pyplot as plt\nimport seaborn\nimport matplotlib.mlab as mlab\n\n#Statistical calculation\nfrom scipy.stats import norm\n\n# We will import the daily data of Amazon from yahoo finance\n# Calculate daily returns\ndf = yf.download(\"AMZN\", \"2020-01-01\", \"2022-01-01\")\ndf = df&#91;&#91;'Close']]\ndf&#91;'returns'] = df.Close.pct_change()\n\n\n# Now we will determine the mean and standard deviation of the daily returns \n# Plot the normal curve against the daily returns\n\nmean = np.mean(df&#91;'returns'])\nstd_dev = np.std(df&#91;'returns'])\n\ndf&#91;'returns'].hist(bins=40, normed=True, histtype='stepfilled', alpha=0.5)\n\nx = np.linspace(mean - 3*std_dev, mean + 3*std_dev, 100)\nplt.plot(x,mlab.normpdf(x, mean, std_dev),\"r\")\nplt.show()<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/63b3dd2be4842d67aa950915b9dbb896#file-var_plot-py\" target=\"_blank\" rel=\"noreferrer noopener\">VaR_plot.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/VaR-calculation-using-Variance-covariance-1-quantinsti.png\" alt=\" class=\" class=\"wp-image-174661 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">Source: Daily data of Amazon from yahoo finance<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Calculate the VaR using point percentile function\nVaR_90 = norm.ppf(1-0.9, mean, std_dev)\nVaR_95 = norm.ppf(1-0.95, mean, std_dev)\nVaR_99 = norm.ppf(1-0.99, mean, std_dev)\nprint (tabulate(&#91;&#91;'90%', VaR_90], &#91;'95%', VaR_95], &#91;'99%', VaR_99]], headers = &#91;'Confidence Level', 'Value at Risk']))<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><a href=\"https:\/\/gist.github.com\/quantra-go-algo\/9670eabea7aae38138a18cfc94ee4ffc#file-calculate_var-py\" target=\"_blank\" rel=\"noreferrer noopener\">Calculate_VaR.py&nbsp;<\/a>hosted with \u2764 by&nbsp;<a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Confidence Level      Value at Risk (%)\n------------------  ---------------\n90%                      -0.0245616\n95%                      -0.031914\n99%                      -0.0457059<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The values above imply the confidence level of the particular \u201cvalue\u201d that is at a risk of being lost. Hence, the confidence rate is 90% that the loss may be -0.0245616 and not more than that.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Similarly, there is a 95% of confidence that the loss of value may be -0.031914 and not more and there is 99% confidence that the loss will go to -0.0457059 and not beyond. Since all the values at risk are in negative, the probability is higher that the portfolio will return more than invested amount.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Visit QuantInsti to read the full article: <a href=\"https:\/\/blog.quantinsti.com\/calculating-value-at-risk-in-excel-python\/\">https:\/\/blog.quantinsti.com\/calculating-value-at-risk-in-excel-python\/<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will understand and perform VaR calculation in Excel and Python using the Historical Method and Variance-Covariance approach, along with examples with this blog.<\/p>\n","protected":false},"author":368,"featured_media":184330,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,343,349,338,350,341,344,9764],"tags":[4922,5878,4659,1225,1224,595,4580,14525,6674],"contributors-categories":[13654],"class_list":["post-184328","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-programing-languages","category-python-development","category-ibkr-quant-news","category-quant-asia-pacific","category-quant-development","category-quant-regions","category-tws-excel-api","tag-econometrics","tag-excel","tag-matplotlib","tag-numpy","tag-pandas","tag-python","tag-seaborn","tag-value-at-risk-var","tag-yfinance","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 v28.1) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Value at Risk (VaR) Calculation in Excel and Python<\/title>\n<meta name=\"description\" content=\"We will understand and perform VaR calculation in Excel and Python using the Historical Method and Variance-Covariance approach, along with examples...\" \/>\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\/184328\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Value at Risk (VaR) Calculation in Excel and Python\" \/>\n<meta property=\"og:description\" content=\"We will understand and perform VaR calculation in Excel and Python using the Historical Method and Variance-Covariance approach, along with examples with this blog.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-27T19:32:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-13T20:18:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/blue-virtual-gradient-quant.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=\"Chainika Thakar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Value at Risk (VaR) Calculation in Excel and Python\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chainika Thakar\" \/>\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\\\/value-at-risk-var-calculation-in-excel-and-python\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/value-at-risk-var-calculation-in-excel-and-python\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Chainika Thakar\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/c97b4c6a477fa019494f67cff50fcb10\"\n\t            },\n\t            \"headline\": \"Value at Risk (VaR) Calculation in Excel and Python\",\n\t            \"datePublished\": \"2023-01-27T19:32:00+00:00\",\n\t            \"dateModified\": \"2023-02-13T20:18:27+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/value-at-risk-var-calculation-in-excel-and-python\\\/\"\n\t            },\n\t            \"wordCount\": 1021,\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\\\/value-at-risk-var-calculation-in-excel-and-python\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/02\\\/blue-virtual-gradient-quant.jpg\",\n\t            \"keywords\": [\n\t                \"Econometrics\",\n\t                \"Excel\",\n\t                \"Matplotlib\",\n\t                \"NumPy\",\n\t                \"Pandas\",\n\t                \"Python\",\n\t                \"Seaborn\",\n\t                \"Value at Risk (VaR)\",\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 Asia Pacific\",\n\t                \"Quant Development\",\n\t                \"Quant Regions\",\n\t                \"TWS Excel API\"\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\\\/value-at-risk-var-calculation-in-excel-and-python\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/value-at-risk-var-calculation-in-excel-and-python\\\/\",\n\t            \"name\": \"Value at Risk (VaR) Calculation in Excel and Python\",\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\\\/value-at-risk-var-calculation-in-excel-and-python\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/value-at-risk-var-calculation-in-excel-and-python\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/02\\\/blue-virtual-gradient-quant.jpg\",\n\t            \"datePublished\": \"2023-01-27T19:32:00+00:00\",\n\t            \"dateModified\": \"2023-02-13T20:18:27+00:00\",\n\t            \"description\": \"We will understand and perform VaR calculation in Excel and Python using the Historical Method and Variance-Covariance approach, along with examples with this blog.\",\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\\\/value-at-risk-var-calculation-in-excel-and-python\\\/\"\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\\\/value-at-risk-var-calculation-in-excel-and-python\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/02\\\/blue-virtual-gradient-quant.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/02\\\/blue-virtual-gradient-quant.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Value at Risk (VaR) Calculation in Excel and 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\\\/c97b4c6a477fa019494f67cff50fcb10\",\n\t            \"name\": \"Chainika Thakar\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/chainikathakar\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Value at Risk (VaR) Calculation in Excel and Python","description":"We will understand and perform VaR calculation in Excel and Python using the Historical Method and Variance-Covariance approach, along with examples...","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\/184328\/","og_locale":"en_US","og_type":"article","og_title":"Value at Risk (VaR) Calculation in Excel and Python","og_description":"We will understand and perform VaR calculation in Excel and Python using the Historical Method and Variance-Covariance approach, along with examples with this blog.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/","og_site_name":"IBKR Campus US","article_published_time":"2023-01-27T19:32:00+00:00","article_modified_time":"2023-02-13T20:18:27+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/blue-virtual-gradient-quant.jpg","type":"image\/jpeg"}],"author":"Chainika Thakar","twitter_card":"summary_large_image","twitter_title":"Value at Risk (VaR) Calculation in Excel and Python","twitter_misc":{"Written by":"Chainika Thakar"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/"},"author":{"name":"Chainika Thakar","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/c97b4c6a477fa019494f67cff50fcb10"},"headline":"Value at Risk (VaR) Calculation in Excel and Python","datePublished":"2023-01-27T19:32:00+00:00","dateModified":"2023-02-13T20:18:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/"},"wordCount":1021,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/blue-virtual-gradient-quant.jpg","keywords":["Econometrics","Excel","Matplotlib","NumPy","Pandas","Python","Seaborn","Value at Risk (VaR)","yfinance"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Asia Pacific","Quant Development","Quant Regions","TWS Excel API"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/","name":"Value at Risk (VaR) Calculation in Excel and Python","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/blue-virtual-gradient-quant.jpg","datePublished":"2023-01-27T19:32:00+00:00","dateModified":"2023-02-13T20:18:27+00:00","description":"We will understand and perform VaR calculation in Excel and Python using the Historical Method and Variance-Covariance approach, along with examples with this blog.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/value-at-risk-var-calculation-in-excel-and-python\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/blue-virtual-gradient-quant.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/blue-virtual-gradient-quant.jpg","width":1000,"height":563,"caption":"Value at Risk (VaR) Calculation in Excel and 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\/c97b4c6a477fa019494f67cff50fcb10","name":"Chainika Thakar","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/chainikathakar\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2023\/02\/blue-virtual-gradient-quant.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/184328","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\/368"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=184328"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/184328\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/184330"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=184328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=184328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=184328"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=184328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}