{"id":2872,"date":"2026-05-14T08:42:08","date_gmt":"2026-05-14T08:42:08","guid":{"rendered":"https:\/\/blogs.mathworks.com\/finance\/?p=2872"},"modified":"2026-05-14T08:42:10","modified_gmt":"2026-05-14T08:42:10","slug":"portfolio-optimization-with-target-factor-exposures","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/finance\/2026\/05\/14\/portfolio-optimization-with-target-factor-exposures\/","title":{"rendered":"Portfolio Optimization with Target Factor Exposures"},"content":{"rendered":"<p><em>A practical MATLAB walkthrough comparing tracking error and exact exposure approaches. <\/em><\/p>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<p>When you build a factor-based portfolio, the central design choice is how strictly to enforce your factor views. Do you treat target exposures as soft goals or do you impose them as hard constraints that the portfolio must satisfy exactly? That decision can materially change the diversification, concentration, and feasibility of the resulting portfolio.<\/p>\n<p>In this blog post, we use data from the Fama-French Data Library, a widely used academic source, to make the comparison practical in a realistic setting. While the example uses the Fama-French three-factor structure\u2014market (Mkt), size (SMB), and value (HML)\u2014the techniques apply to any multi-factor framework.<\/p>\n<p>We compare two practical optimization approaches using MATLAB\u00ae:<\/p>\n<ol type=\"1\" start=\"1\">\n<li><strong>Tracking Error Minimization<\/strong>\u2014Targets specific factor exposures while allowing small deviations, which can improve diversification and feasibility.<\/li>\n<li><strong>Exact Exposure Matching<\/strong>\u2014Enforces target factor exposures exactly using equality constraints, which is useful when strict mandates or regulatory requirements must be met.<\/li>\n<\/ol>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<div class=\"is-horizontal is-content-justification-left is-layout-flex wp-container-1 wp-block-buttons\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-white-color has-text-color has-background wp-element-button\" href=\"https:\/\/www.mathworks.com\/help\/finance\/optimize-portfolio-with-Fama-French-model.html\" style=\"background-color:#0076a8\" target=\"_blank\" rel=\"noreferrer noopener\">Explore the example<\/a><\/div>\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-white-color has-text-color has-background wp-element-button\" href=\"https:\/\/www.mathworks.com\/videos\/portfolio-optimization-with-target-factor-exposures-1777528702639.html\" style=\"background-color:#0076a8\" target=\"_blank\" rel=\"noreferrer noopener\">Watch the demo video<\/a><\/div>\n<\/div>\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h1><strong>1. Load Data and Set Up the Factor Model<\/strong><\/h1>\n<p>We start with one year of price data for the 30 stocks in the Dow Jones Industrial Average\u00ae (DJIA), which we convert to returns. Separately, we load the three Fama-French factors: excess market return (Mkt), small minus big (SMB), and high minus low (HML).<\/p>\n<p>After synchronizing the stock and factor data, MATLAB estimates the joint covariance structure using a <span style=\"font-family: monospace;\">Portfolio<\/span> object. In the tracking error formulation, the factor return series are included in that covariance structure even though they are not investable assets. This setup allows the optimization to reflect both stock-return risk and the portfolio\u2019s relationship to the factor returns.<\/p>\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h1><strong>2. Apply Realistic Constraints<\/strong><\/h1>\n<p>Both approaches share the same set of practical constraints:<\/p>\n<ul>\n<li><strong>Conditional weight bounds:<\/strong>&nbsp;Each stock can either be excluded from the portfolio or, if selected, must hold between 5% and 20%. This keeps positions large enough to matter and small enough to maintain diversification.<\/li>\n<li><strong>Cardinality limit:<\/strong>&nbsp;The portfolio holds at most 10 stocks. This practical constraint introduces binary asset-selection decisions, making the optimization mixed-integer.<\/li>\n<li><strong>Full investment:<\/strong>&nbsp;All stock weights sum to 100%, so all capital is invested.<\/li>\n<li><strong>Factor weights fixed at zero:<\/strong>&nbsp;The factor data series are present in the <span style=\"font-family: monospace;\">Portfolio<\/span> object for covariance estimation, but the optimizer cannot allocate capital to them. Setting their upper and lower bounds to zero enforces this.<\/li>\n<\/ul>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h1 id=\"3-approach-1--minimize-tracking-error-to-factor-targets\">3. Approach 1 \u2014 Minimize Tracking Error to Factor Targets<\/h1>\n<p>This approach finds a portfolio whose factor exposures are close to \u2014 but not required to exactly match \u2014 a set of predefined targets. In MATLAB, the benchmark is represented by zero weights on all stocks and nonzero weights only on the three factors. The optimization then minimizes tracking error relative to that benchmark.<\/p>\n<h2 id=\"target-factor-exposures\">Target Factor Exposures<\/h2>\n<ul>\n<li>Positive exposure to the overall market (Mkt = 0.013)<\/li>\n<li>A tilt toward large-cap stocks rather than small-cap stocks (SMB = -0.003)<\/li>\n<li>A modest tilt toward value over growth (HML = 0.001)<\/li>\n<\/ul>\n<h2 id=\"how-the-formulation-works\">How the Formulation Works<\/h2>\n<p>In this formulation, the Fama\u2013French risk factor return series are included in the <span style=\"font-family: monospace;\">Portfolio<\/span> object together with the stock returns, but their weights are fixed at zero. That means the optimizer cannot allocate capital to the factors, even though their return behavior still influences the covariance structure. This lets the tracking error objective guide the portfolio toward the desired factor exposures without introducing a separate factor covariance model.<\/p>\n<p>In the example, MATLAB solves the custom objective with <span style=\"font-family: monospace;\">estimateCustomObjectivePortfolio<\/span> after configuring the mixed-integer solver with <span style=\"font-family: monospace;\">setSolverMINLP<\/span>. The resulting tracking error portfolio uses all 10 available stock slots.<\/p>\n<h2 id=\"results\">Results<\/h2>\n<p>The optimizer selects a diversified set of 10 stocks while satisfying all portfolio constraints.<\/p>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"560\" height=\"337\" src=\"https:\/\/blogs.mathworks.com\/finance\/files\/2026\/04\/Pie-chart.png\" alt=\"\" class=\"wp-image-2882\"\/><figcaption class=\"wp-element-caption\">Asset weights for the tracking error portfolio, showing a diversified allocation across 10 stocks<\/figcaption><\/figure>\n<\/div>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<p>The resulting portfolio-level exposures are close to the targets, but do not match exactly:<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td><strong>Factor<\/strong><\/td>\n<td><strong>Target<\/strong><\/td>\n<td><strong>Achieved<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Market<\/td>\n<td>0.0130<\/td>\n<td>0.0116<\/td>\n<\/tr>\n<tr>\n<td>SMB<\/td>\n<td>-0.0030<\/td>\n<td>-0.0030<\/td>\n<\/tr>\n<tr>\n<td>HML<\/td>\n<td>0.0010<\/td>\n<td>0.0013<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h2>When This Approach Works Well<\/h2>\n<ul>\n<li>You want flexibility around factor targets rather than rigid compliance.<\/li>\n<li>Diversification and feasibility matter more than exact factor matching.<\/li>\n<li>You are willing to accept small exposure drift in exchange for a broader, more balanced selection of assets.<\/li>\n<\/ul>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h1><strong>4. Approach 2 \u2014 Match Factor Exposures Exactly<\/strong><\/h1>\n<p>This approach guarantees that the portfolio&#8217;s factor exposures hit the targets precisely. Here, factor data are excluded from the <span style=\"font-family: monospace;\">Portfolio<\/span> object entirely. Instead, MATLAB uses the estimated factor loading matrix <strong>Beta<\/strong> to impose equality constraints of the form <strong>Beta&#8217; <em>* w =<\/em> Target Exposure<\/strong>.<\/p>\n<p>The optimization then solves for the minimum-risk portfolio subject to these constraints along with the same weight, cardinality, and budget constraints used in Approach 1.<\/p>\n<h2><strong>Results<\/strong><\/h2>\n<p>The resulting portfolio-level exposures match the targets exactly:<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<td><strong>Factor<\/strong><\/td>\n<td><strong>Target<\/strong><\/td>\n<td><strong>Achieved<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Market<\/td>\n<td>0.0130<\/td>\n<td>0.0130<\/td>\n<\/tr>\n<tr>\n<td>SMB<\/td>\n<td>-0.0030<\/td>\n<td>-0.0030<\/td>\n<\/tr>\n<tr>\n<td>HML<\/td>\n<td>0.0010<\/td>\n<td>0.0010<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<p>Because the target exposures are enforced directly, the achieved portfolio-level exposures match the targets exactly. The trade-off is reduced freedom for the optimizer, which can lead to fewer holdings, higher concentration, worse risk-return trade-offs, or even infeasibility when the targets are too restrictive.<\/p>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"560\" height=\"337\" src=\"https:\/\/blogs.mathworks.com\/finance\/files\/2026\/04\/second-pie.png\" alt=\"\" class=\"wp-image-2883\"\/><figcaption class=\"wp-element-caption\">Asset weights for the exact exposure portfolio, showing a more concentrated allocation across fewer stocks <\/figcaption><\/figure>\n<\/div>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h2><strong>When This Approach Works Well<\/strong><\/h2>\n<ul>\n<li>You must meet regulatory or mandate-driven factor targets precisely.<\/li>\n<li>You need for strict control over portfolio factor exposures.<\/li>\n<\/ul>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h1><strong>5. Comparing the Two Approaches<\/strong><\/h1>\n<p>A side-by-side view of the asset weights makes the trade-offs concrete.<\/p>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"560\" height=\"337\" src=\"https:\/\/blogs.mathworks.com\/finance\/files\/2026\/04\/tracking-error-vs-exact-exposure-weight-comparison.png\" alt=\"\" class=\"wp-image-2884\"\/><figcaption class=\"wp-element-caption\">Grouped bar chart &#8211; comparison of asset weights for the tracking error and exact exposure portfolios<\/figcaption><\/figure>\n<\/div>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h1>6. Wrap Up<\/h1>\n<p>Choosing between these approaches depends on whether flexibility or precision is the primary objective. Tracking error minimization trades small deviations for better diversification and stronger feasibility under practical constraints. Exact exposure matching guarantees target compliance, but it can do so at the cost of diversification.<\/p>\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<h1>Learn More<\/h1>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/finance\/optimize-portfolio-using-fama-french-model.html\">Optimize Portfolio Using Fama-French Model<\/a>&nbsp;\u2014 Full example with code, data, and interactive charts<\/li>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/finance\/portfolio-optimization-using-factor-models.html\">Portfolio Optimization Using Factor Models<\/a>&nbsp;\u2014 Broader overview of factor-based portfolio optimization in Financial Toolbox\u2122<\/li>\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.mathworks.com\/videos\/portfolio-optimization-with-target-factor-exposures-1777528702639.html\" target=\"_blank\">Portfolio Optimization with Target Factor Exposures &#8211; video<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/finance\/files\/2026\/04\/Pie-chart.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>A practical MATLAB walkthrough comparing tracking error and exact exposure approaches. <\/p>\n<p>When you build a factor-based portfolio, the central design choice is how strictly to enforce your factor&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/finance\/2026\/05\/14\/portfolio-optimization-with-target-factor-exposures\/\">read more >><\/a><\/p>\n","protected":false},"author":233,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22,4,19],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/posts\/2872"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/users\/233"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/comments?post=2872"}],"version-history":[{"count":14,"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/posts\/2872\/revisions"}],"predecessor-version":[{"id":2904,"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/posts\/2872\/revisions\/2904"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/media?parent=2872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/categories?post=2872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/finance\/wp-json\/wp\/v2\/tags?post=2872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}