{"id":56034,"date":"2020-08-13T11:45:21","date_gmt":"2020-08-13T15:45:21","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=56034"},"modified":"2024-05-17T15:28:29","modified_gmt":"2024-05-17T19:28:29","slug":"portfolio-optimisation-with-mlfinlab-estimation-of-risk","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/","title":{"rendered":"Portfolio Optimisation with MlFinLab: Estimation of Risk"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/hudsonthames.org\/wp-content\/uploads\/sites\/2\/2020\/07\/img2.png\" alt=\"Portfolio Optimisation with MlFinLab\" title=\"Correlation and Covariance Heatmap of a Portfolio of Assets\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/><\/figure>\n\n\n\n<p><a href=\"https:\/\/intelligent.schwab.com\/public\/intelligent\/insights\/whitepapers\/asset-allocation.html\"><em>Image Credits:&nbsp;<\/em>Schwab Intelligent Portfolios\u2122 Asset Allocation White Paper<\/a><\/p>\n\n\n\n<p>Risk has always played a very large role in the world of finance with the performance of a large number of investment and trading strategies being dependent on the efficient estimation of underlying market risk. With regards to this, one of the most popular and commonly used representation of risk in finance is through a covariance matrix \u2013 higher covariance values mean more volatility in the markets and vice-versa. This also comes with a caveat \u2013 empirical covariance values are always measured using historical data and are extremely sensitive to small changes in market conditions. This makes the covariance matrix an unreliable estimator of the true risk and calls for a need to have better estimators.<\/p>\n\n\n\n<p>In this post we will use the RiskEstimators class from MlFinLab which provides several implementations for different ways to calculate and adjust the empirical covariance matrices. Some of these try to remove inherent outliers from the matrix while others focus on removing noise from the empirical values. Throughout this blog post, we will look at a quick description of each algorithm as well as see how we can use the corresponding implementation provided in MlFinLab.<\/p>\n\n\n\n<p>The RiskEstimators class covers seven different algorithms relating to covariance matrix estimators. These algorithms include:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Minimum Covariance Determinant<\/li><li>Empirical Covariance<\/li><li>Covariance Estimator with Shrinkage<\/li><li>Semi-Covariance Matrix<\/li><li>Exponentially-Weighted Covariance matrix<\/li><li>De-Noising Covariance Matrix<\/li><li>Covariance and Correlation Matrix Transformations<\/li><\/ul>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;The descriptions of these algorithms are all based upon the descriptions from the&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/covariance.html#robust-covariance\">scikit-learn User Guide on Covariance Estimation<\/a>. Infact, most of the methods (except the denoising and detoning ones) in the class are wrappers of sklearn\u2019s covariance methods but with the added functionality of working specifically with financial data e.g. having inbuilt returns calculation.<\/p>\n\n\n\n<p>We will import the required libraries and the dataset \u2013 a small subset of historical prices of ETFs.<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n# importing our required libraries<br>\nimport numpy as np<br>\nimport pandas as pd<br>\nimport matplotlib.pyplot as plt<br>\nimport mlfinlab as ml<br>\n<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n# reading in our data<br>\nstock_prices = pd.read_csv(&#8216;stock_prices.csv&#8217;, parse_dates=True, index_col=&#8217;Date&#8217;)<br>\nstock_prices = stock_prices.dropna(axis=1)\n<\/p>\n\n\n\n<p>For the purpose of this post, we will only use 5 assets, so the differences between the calculated covariance matrices are easy to see.<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\nstock_prices = stock_prices.iloc[:, :5]<br>\nstock_prices.head()\n<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" data-src=\"https:\/\/hudsonthames.org\/wp-content\/uploads\/sites\/2\/2020\/07\/Screen-Shot-2020-07-25-at-4.57.34-PM.png\" alt=\"\" class=\"wp-image-5029 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Minimum Covariance Determinant<\/h2>\n\n\n\n<p>The Minimum Covariance Determinant (MCD) is a robust estimator of covariance that was introduced by P.J. Rousseeuw. From the scikit-learn User Guide on Covariance Estimation, \u201cthe basic idea of the algorithm is to find a set of observations that are not outliers and compute their empirical covariance matrix, which is then rescaled to compensate for the performed selection of observations\u201d. The MlFinLab implementation is a wrap around sklearn\u2019s MinCovDet class, which uses FastMCD algorithm, developed by Rousseeuw and Van Driessen. A detailed description of the algorithm is available in the paper by&nbsp;<em>Mia Hubert<\/em>&nbsp;and&nbsp;<em>Michiel Debruyne<\/em>&nbsp;\u2013&nbsp;<a href=\"https:\/\/wis.kuleuven.be\/stat\/robust\/papers\/2010\/wire-mcd.pdf\"><strong>Minimum Covariance Determinant.<\/strong><\/a><\/p>\n\n\n\n<p>First, we can construct a simple (empirical) covariance matrix for comparison.# A class with function to calculate returns from pricesreturns_estimation = ml.portfolio_optimization.ReturnsEstimators()# Calcualting the data set of returnsstock_returns = returns_estimation.calculate_returns(stock_prices)# Finding the simple covariance matrix from a series of returnscov_matrix = stock_returns.cov()<\/p>\n\n\n\n<p>We can now construct the MCD matrix. One can use&nbsp;<em><code>minimum_covariance_determinant()<\/code>&nbsp;<\/em>method for this purpose.<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n# A class that has the Minimum Covariance Determinant estimator<br>\nrisk_estimators = ml.portfolio_optimization.RiskEstimators()<br><br>\n# Finding the Minimum Covariance Determinant estimator on price data and with set random seed to 0<br>\nmin_cov_det = risk_estimators.minimum_covariance_determinant(stock_prices, price_data=True, random_state=0)<br><br>\n# Transforming our estimation from a np.array to pd.DataFrame<br>\nmin_cov_det = pd.DataFrame(min_cov_det, index=cov_matrix.index, columns=cov_matrix.columns)\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/hudsonthames.org\/wp-content\/uploads\/sites\/2\/2020\/07\/normal-cov.png\" alt=\"\" title=\"Simple Covariance Matrix\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/hudsonthames.org\/wp-content\/uploads\/sites\/2\/2020\/07\/minimum-cov.png\" alt=\"\" title=\"Minimum Covariance Matrix\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/hudsonthames.org\/wp-content\/uploads\/sites\/2\/2020\/07\/simple_cov-e1595717728217.png\" alt=\"\" title=\"Simple Covariance Heatmap\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/hudsonthames.org\/wp-content\/uploads\/sites\/2\/2020\/07\/min_cov-e1595717748971.png\" alt=\"\" title=\"Minimum Covariance Heatmap\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/><\/figure>\n\n\n\n<p>From the above images, you can see that the absolute values in the Minimum Covariance Determinant estimator are lower in comparison to the simple Covariance matrix, which means that the algorithm has eliminated some of the outliers in the data and the resulting covariance matrix estimator is a more robust one. Note that this method achieves the best result when the data has outliers in it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Maximum Likelihood Covariance Estimator (Empirical Covariance)<\/h2>\n\n\n\n<p>Maximum Likelihood Estimator of a sample is an unbiased estimator of the corresponding population\u2019s covariance matrix. This estimation works well when the number of observations is big enough in relation to the number of features.<\/p>\n\n\n\n<p>We can implement this algorithm through the&nbsp;<em>empirical_covariance method()<\/em>&nbsp;in the MlFinLab library.<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n# Finding the Empirical Covariance on price data<br>\nempirical_cov = risk_estimators.empirical_covariance(stock_prices, price_data=True)<br><br>\n# Transforming Empirical Covariance from np.array to pd.DataFrame<br>\nempirical_cov = pd.DataFrame(empirical_cov, index=cov_matrix.index, columns=cov_matrix.columns)\n<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/hudsonthames.org\/wp-content\/uploads\/sites\/2\/2020\/07\/normal-cov.png\" alt=\"\" title=\"Simple Covariance Matrix\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/hudsonthames.org\/wp-content\/uploads\/sites\/2\/2020\/07\/empirical_covariance.png\" alt=\"\" title=\"Empirical Covariance Matrix\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" \/><\/figure>\n\n\n\n<p>One can observe that the Empirical Covariance is the same as the standard covariance function from the pandas package i.e. the&nbsp;<em><code>cov()<\/code>&nbsp;<\/em>&nbsp;function.<\/p>\n\n\n\n<p>Visit Hudson and Thames Quantitative Research website to read the full article and download practical code:<br><a href=\"https:\/\/hudsonthames.org\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/\">https:\/\/hudsonthames.org\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hudson and Thames demonstrates how to use Python and the MlFinLab package for portfolio optimisation and risk analysis.<\/p>\n","protected":false},"author":186,"featured_media":22246,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":true,"footnotes":""},"categories":[339,343,349,338,341,352,344],"tags":[8215,8214,4659,8216,8212,1225,1224,8213,8217,595,4135],"contributors-categories":[13707],"class_list":{"0":"post-56034","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":"category-quant-north-america","13":"category-quant-regions","14":"tag-empirical-covariance","15":"tag-estimation-of-risk","16":"tag-matplotlib","17":"tag-minimum-covariance-determinant","18":"tag-mlfinlab","19":"tag-numpy","20":"tag-pandas","21":"tag-portfolio-optimisation","22":"tag-pyplot","23":"tag-python","24":"tag-risk-management","25":"contributors-categories-hudson-and-thames-quantitative-research"},"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>Portfolio Optimisation with MlFinLab: Estimation of Risk<\/title>\n<meta name=\"description\" content=\"Hudson and Thames demonstrates how to use Python and the MlFinLab package for portfolio optimisation and risk analysis.\" \/>\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\/56034\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Portfolio Optimisation with MlFinLab: Estimation of Risk | IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"Hudson and Thames demonstrates how to use Python and the MlFinLab package for portfolio optimisation and risk analysis.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-13T15:45:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-17T19:28:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/money-symbols.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"700\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Contributor Author\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Contributor Author\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Contributor Author\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/e823e46b42ca381080387e794318a485\"\n\t            },\n\t            \"headline\": \"Portfolio Optimisation with MlFinLab: Estimation of Risk\",\n\t            \"datePublished\": \"2020-08-13T15:45:21+00:00\",\n\t            \"dateModified\": \"2024-05-17T19:28:29+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/\"\n\t            },\n\t            \"wordCount\": 856,\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\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/money-symbols.jpg\",\n\t            \"keywords\": [\n\t                \"Empirical Covariance\",\n\t                \"Estimation of Risk\",\n\t                \"Matplotlib\",\n\t                \"Minimum Covariance Determinant\",\n\t                \"MlFinLab\",\n\t                \"NumPy\",\n\t                \"Pandas\",\n\t                \"Portfolio Optimisation\",\n\t                \"Pyplot\",\n\t                \"Python\",\n\t                \"risk management\"\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                \"Quant North America\",\n\t                \"Quant Regions\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/\",\n\t            \"name\": \"Portfolio Optimisation with MlFinLab: Estimation of Risk | 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\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/money-symbols.jpg\",\n\t            \"datePublished\": \"2020-08-13T15:45:21+00:00\",\n\t            \"dateModified\": \"2024-05-17T19:28:29+00:00\",\n\t            \"description\": \"Hudson and Thames demonstrates how to use Python and the MlFinLab package for portfolio optimisation and risk analysis.\",\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\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/\"\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\\\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/money-symbols.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2019\\\/10\\\/money-symbols.jpg\",\n\t            \"width\": 1100,\n\t            \"height\": 700,\n\t            \"caption\": \"Tech Dividends\"\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\\\/e823e46b42ca381080387e794318a485\",\n\t            \"name\": \"Contributor Author\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/contributor-author\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Portfolio Optimisation with MlFinLab: Estimation of Risk","description":"Hudson and Thames demonstrates how to use Python and the MlFinLab package for portfolio optimisation and risk analysis.","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\/56034\/","og_locale":"en_US","og_type":"article","og_title":"Portfolio Optimisation with MlFinLab: Estimation of Risk | IBKR Quant Blog","og_description":"Hudson and Thames demonstrates how to use Python and the MlFinLab package for portfolio optimisation and risk analysis.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/","og_site_name":"IBKR Campus US","article_published_time":"2020-08-13T15:45:21+00:00","article_modified_time":"2024-05-17T19:28:29+00:00","og_image":[{"width":1100,"height":700,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/money-symbols.jpg","type":"image\/jpeg"}],"author":"Contributor Author","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Contributor Author","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/"},"author":{"name":"Contributor Author","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/e823e46b42ca381080387e794318a485"},"headline":"Portfolio Optimisation with MlFinLab: Estimation of Risk","datePublished":"2020-08-13T15:45:21+00:00","dateModified":"2024-05-17T19:28:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/"},"wordCount":856,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/money-symbols.jpg","keywords":["Empirical Covariance","Estimation of Risk","Matplotlib","Minimum Covariance Determinant","MlFinLab","NumPy","Pandas","Portfolio Optimisation","Pyplot","Python","risk management"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Development","Quant North America","Quant Regions"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/","name":"Portfolio Optimisation with MlFinLab: Estimation of Risk | IBKR Quant Blog","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/money-symbols.jpg","datePublished":"2020-08-13T15:45:21+00:00","dateModified":"2024-05-17T19:28:29+00:00","description":"Hudson and Thames demonstrates how to use Python and the MlFinLab package for portfolio optimisation and risk analysis.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/portfolio-optimisation-with-mlfinlab-estimation-of-risk\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/money-symbols.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/money-symbols.jpg","width":1100,"height":700,"caption":"Tech Dividends"},{"@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\/e823e46b42ca381080387e794318a485","name":"Contributor Author","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/contributor-author\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2019\/10\/money-symbols.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/56034","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\/186"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=56034"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/56034\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/22246"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=56034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=56034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=56034"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=56034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}