<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vijayalakshmi Pai on Medium]]></title>
        <description><![CDATA[Stories by Vijayalakshmi Pai on Medium]]></description>
        <link>https://medium.com/@pai.viji?source=rss-479eaa23ba8b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*nlWnTF64B5MHaLGuga7Rjg.png</url>
            <title>Stories by Vijayalakshmi Pai on Medium</title>
            <link>https://medium.com/@pai.viji?source=rss-479eaa23ba8b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 13:41:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pai.viji/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Portfolio Rebalancing — the Optimal Buy-Sell Dilemma!]]></title>
            <link>https://medium.com/@pai.viji/portfolio-rebalancing-the-optimal-buy-sell-dilemma-d166787712b9?source=rss-479eaa23ba8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d166787712b9</guid>
            <category><![CDATA[portfolio-rebalancing]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[sharpe-ratio]]></category>
            <category><![CDATA[metaheuristics]]></category>
            <category><![CDATA[buy-sell]]></category>
            <dc:creator><![CDATA[Vijayalakshmi Pai]]></dc:creator>
            <pubDate>Thu, 25 Mar 2021 10:55:45 GMT</pubDate>
            <atom:updated>2021-03-25T10:55:45.286Z</atom:updated>
            <content:encoded><![CDATA[<h3>Portfolio Rebalancing — the Optimal Buy-Sell Dilemma!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*thB9WHbZsgxrfHgEymROPg.png" /><figcaption>Portfolio Rebalancing — the perfect balancing act for ‘risk-adjusted-returns’?</figcaption></figure><h3><strong><em>1. Introduction</em></strong></h3><p><strong><em>Asset Allocation </em></strong>which concerns itself with the optimal allocation of capital to be invested in assets of a portfolio subject to the investor’s risk-return appetite and investment goals, is a key factor in determining the long time investment performance.</p><p>However, <em>it is not a one-time deal</em> since market forces tend to fluctuate and a portfolio kept <strong><em>untended </em></strong>for long can drift to a state that incurs exposure to more risk, which is not in sync with the investor’s risk appetite and investment preferences. Hence the need to <strong><em>rebalance</em></strong> a portfolio.</p><h3><strong>2. What is Portfolio Rebalancing?</strong></h3><p><strong><em>Rebalancing a portfolio</em></strong> deals with <strong><em>buying</em></strong> and <strong><em>selling </em></strong>components of the portfolio to set the portfolio weights to satisfy their original goals or to devise a new asset allocation by readjusting the weights of each asset to realign the risk-return characteristics of the drifted portfolio. (See Chapter 7 of [PAI 2018] to know more about rebalancing of portfolios)</p><h4>Illustration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*gjLtCVGClQcqJIGOl6rS4Q.png" /></figure><p>Radha and Ram are two investors who chose to invest 60% of their capital in equity funds and 40% in bond funds on Jan 2, 2016.</p><p>The portfolio was kept untended for a year.</p><p>After a year, on Jan 2, 2017 they observed that with the equities outperforming bonds in the markets, the allocation of assets in their portfolios had changed to 71% equities and 29% bonds, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*zNgwbONa0Ce98ufefRYbjQ.png" /></figure><p>Now, Radha being a risk-averse investor decides to rebalance her portfolio, while Ram chose to hold on to his portfolio pleased with the returns fetched by the untended portfolio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*gihOqwl2jah6OgjRFTOeLg.png" /></figure><p>One year later, markets turn turbulent with the equity funds performing poorly losing 10% while the bond funds performed well appreciating 15%. Radha and Ram review their portfolios only to find that while Radha’s rebalanced portfolio was able to cushion her from the market turbulence with 0% losses, Ram’s unbalanced portfolio suffered a loss of 2.8%!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*RgAaL-WRz7noXyEZvLS_xA.png" /></figure><p>Despite the need, portfolio rebalancing has its costs too, since buying and selling of assets incur transaction costs besides capital gains taxes, administrative costs and/or management fees, which can eat into the returns of the rebalanced portfolio. We term these generally as <strong><em>Transaction Costs</em></strong>. If the transaction costs can be accommodated within the gains made by the rebalanced portfolio leaving a respectable return, then such a portfolio is termed as a <strong><em>self-financing portfolio</em></strong>.</p><h3>3. Optimal Portfolio Rebalancing</h3><p>The objective of this work is to demonstrate an <strong><em>optimal portfolio rebalancing model</em></strong> that will, (i) arrive at the optimal buy/sell decisions with regard to the assets in the portfolio (ii) ensure that the optimal rebalanced portfolio is a self financing portfolio (iii) ensure that the risk of the rebalanced portfolio <strong>does not exceed</strong> that of the original portfolio’s risk (iv) see to it that no buy and sell limits set by the investor, are violated during rebalancing and (v) establish the rebalanced portfolio to be a fully invested portfolio.</p><p>The optimal portfolio rebalancing model employs <strong><em>metaheuristics </em></strong>to arrive at the optimal buy/sell weights that will yield a rebalanced portfolio which satisfies the constraints specified above. <strong><em>The objective of the model is to maximize the Sharpe Ratio of the rebalanced portfolio.</em></strong></p><p>Assets that need to be bought (increase in asset weights) will be referred to as BUY assets and those that need to be sold (decrease in asset weights) will be referred to as SELL assets.</p><h3>4. Construction of an Optimal Rebalanced Portfolio</h3><p>Let us consider an investor who desires to construct a rebalanced self-financing portfolio with maximum Sharpe Ratio and subject to the constraints that reflect restrictions on asset allocation and the investor’s preferences.</p><p>The <strong><em>objective function</em></strong> of the model is,</p><p>(1) To maximize the Sharpe Ratio of the rebalanced portfolio</p><p>(See <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson6_SharpeRatioOptimization/Lesson6_MainContent.ipynb">https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson6_SharpeRatioOptimization/Lesson6_MainContent.ipynb </a>to know about Sharpe Ratio based portfolio optimization)</p><p>The <strong><em>constraints</em></strong> are,</p><p>(2) Bounds on the weights of BUY assets, where the investor specifies limits on how much can be bought maximum.<br> <br> (3) Bounds on the weights of SELL assets, where the investor specifies limits on how much can be sold maximum.<br> <br> (4) A budget constraint on the portfolio, where the capital is fully invested, (i.e.) the sum of the rebalanced portfolio weights equals 1.<br> <br> (5) the rebalanced portfolio is a self financing portfolio.<br> <br> (6) the rebalanced portfolio risk does not exceed the original portfolio risk.</p><h3>5. Mathematical Formulation of the Optimal Portfolio Rebalancing Model</h3><p>Let us suppose that an investor has invested in a portfolio <em>P{Original}</em> comprising <em>N </em>assets, with the weight allocation given by vector <em>W</em> and let <em>Risk{Original} </em>be the risk of the original portfolio.</p><p>Let us also suppose that the portfolio was kept untended for long and the investor decides to rebalance the portfolio one fine day! Let <em>P{Rebal}</em> be the rebalanced portfolio to obtain which, the optimal buy/sell weights need to be determined.</p><p>Let vector <em>X </em>be the desired optimal allocation of weights of the rebalanced portfolio. Let <em>xi+</em> and <em>xi-</em> be the proportion of weights that need to be bought or sold of the BUY assets and SELL assets and hence need to be added or subtracted from vector <em>W</em> of <em>P{Original}</em>, respectively.</p><p>For computational convenience we assume that the buy/sell decision with regard to asset <em>i </em>is characterized by a mutually exclusive pair <em>[xi+, xi-]</em>, where <em>xi- = 0</em>, if it is a buy decision and <em>xi+ = 0</em>, if it is a sell decision.</p><p>Let <em>p</em> be the transaction cost rate and <em>ui</em> be the upper limit of the buy weights. <em>ui</em> acts as a ceiling to curtail the transaction costs, which can disrupt realizing a self financing portfolio that the investor expects.</p><p>Let vector <em>μ</em> be the asset returns for the historical data set considered for portfolio rebalancing and <em>V</em> be the variance-covariance matrix of asset returns for the said period, which are essential for computing the risk and return of a portfolio (See <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson1_FundaRiskReturnPortfolio/Lesson1_MainContent.ipynb">https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson1_FundaRiskReturnPortfolio/Lesson1_MainContent.ipynb,</a> to know about risk and return of a portfolio)</p><p>Let <em>Rf</em> be the risk free rate of return.</p><p>The portfolio rebalancing model is defined as,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*dUr4hjtY4-gRMMHWhwTo7Q.png" /></figure><p>The objective of the portfolio rebalancing model defined by equations (1)-(7) is to find the optimal rebalanced portfolio weights X, which is dependent on the optimal buy/sell weights <em>xi+ </em>and <em>xi-</em>.</p><h3>6. Metaheuristic Optimization</h3><p>We proceed to undertake the optimization of the model described by equations (1) to (7) employing a <strong><em>metaheuristic strategy </em></strong>viz., <strong><em>Evolution Strategy with Hall of Fame (ES HOF)</em></strong>. ES HOF arrives at the optimal weights of the rebalanced portfolio that yield maximal Sharpe Ratio, subject to all the constraints enforced on the assets and the portfolio.</p><p>(See Chapter 2: A Brief Primer on Metaheuristics [PAI 2018], to know more about metaheuristics and Evolution Strategy with Hall of Fame )</p><p>Metaheuristic strategies build <strong><em>feasible solution sets</em></strong> that satisfy the constraints imposed, during the course of their execution process. However <strong><em>constraint handling</em></strong> has been a major problem in the application of metaheuristic strategies to complex constrained optimization problems, to tackle which several methods such as <strong><em>Penalty Function Strategy</em></strong> and <strong><em>Repair Strategy</em></strong> have been proposed.</p><p>For the Portfolio Rebalancing model discussed in this work, ES HOF makes use of Joines and Houck’s <strong><em>Dynamic Penalty Function Strategy</em></strong> [JOI 1994] to handle the constraint that imposes a ceiling on the rebalanced portfolio risk (equation (7)) and <strong><em>Repair Strategies </em></strong>to handle the bounds constraints on the buy/sell weights, the budget constraint on the rebalanced portfolio as well the self financing portfolio constraints (equations (2) to (6)).</p><p>Repair strategies are custom made to suit the requirements of the problem and evolving such a strategy that will help satisfy one or more constraints at one go, can turn out to be difficult. Nevertheless, once the strategy is evolved, it can help churn out populations of feasible solution sets during each of the generation cycles, leading to faster convergence of the metaheuristic strategy.</p><p>(See Sec. 7.3.3 of Chapter 7: Metaheuristic Portfolio Rebalancing with Transaction Costs [PAI 2018], to know more about the Repair Strategies evolved for the Portfolio Rebalancing model)</p><h3>7. Transformation of the Mathematical Model</h3><p>Joines and Houck’s dynamic penalty function strategy is used to tackle the constraint represented by equation (7). The constraint is accommodated in the “penalized” objective function by defining appropriate penalty functions. The transformed mathematical model is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*JRwLErM2rtECk20Jb-PewQ.png" /></figure><p>In the system of equations (8), the function <em>ψ </em>denotes the<em> constraint violation function. (C, α, β) </em>are all constants and the penalty term <em>(C.t)</em> to the power of <em>α</em> increases constantly with each generation count <em>t</em> of the metaheuristic strategy ES HOF. <em>ε</em> is a tolerance limit for testing the inequality constraint represented by <em>φ</em> .</p><p>The transformed portfolio rebalancing model with equation (8) as its objective function and equations (2–6) as its constraints is solved using the metaheuristic strategy ES HOF.</p><h3>8. Evolution Strategy with Hall of Fame — a run through!</h3><p>ES HOF is a population based metaheuristic strategy that evokes <strong><em>elitism</em> </strong>using <strong><em>Hall of Fame</em></strong> (See Section 2.4 of Chapter2 of [PAI 2018] to know more about ES HOF).</p><p>The inputs, process and output of ES HOF are described below:</p><h4><strong>Inputs</strong></h4><p>It is essential that the <strong><em>portfolio rebalancing parameters </em></strong>and the <strong><em>ES HOF strategy parameters</em></strong> are clearly set, before the optimization process begins.</p><p>The portfolio rebalancing parameters are (1) assets in the untended portfolio (2) mean asset returns and covariance of returns (the variance-covariance matrix of returns) for the historical period up till the day on which rebalancing is executed (3) bounds for the buy/sell weights (4) transaction cost rate and (5) risk free rate of return.<br>The weights <em>W</em> of the original portfolio and its risk <em>Risk{Original}</em> are also input.</p><p>The ES HOF parameters are (1) population size (2) number of generations (3) dynamic penalty function parameters <em>(C, α, β) </em>(4) crossover rate and (5) mutation rate.</p><h4><strong>Process</strong></h4><p>ES HOF begins its execution by generating an <strong><em>initial random population of chromosomes/individuals</em></strong> that represent random buy/sell weights <em>xi+, xi-</em> for the assets in the portfolio.</p><p>In the first stage, the population is <strong><em>normalized</em></strong> to enable each of the randomly generated buy/sell weights to satisfy the respective bounds described by equations (2)-(3).</p><p>In the second stage, a <strong><em>weight repair strategy</em></strong> is evolved so that the normalized population of chromosomes satisfies all the constraints described by equations (2)-(6), enabling it to transform itself into a feasible solution set. Let us call this population P.</p><p>Using the rebalanced weights X represented by population P, fitness function values are computed employing the penalized objective function described by equation (8).</p><p>Set population P as the parent population.</p><p>Obtain its offspring population by applying the genetic inheritance operators of <strong><em>arithmetic variable point cross over</em></strong> and <strong><em>real number uniform mutation</em></strong>.</p><p>Normalize the offspring population to enable them satisfy their respective bounds for the buy/sell weights and transform them into a feasible solution set by using the weight repair strategy. Call the population O.</p><p>Obtain the rebalanced weights for the population O of chromosomes and compute its fitness values using equation (8).</p><p>Select the best fit individuals of the population P and O in the ratio of <em>μ: λ.</em> Call the population NEXTGEN.</p><p>Select the best fit chromosome from among NEXTGEN and induct it into the Hall of Fame, after allowing it to compete with the individual already in it.</p><p>Set NEXTGEN as the parent population P for the next generation and repeat the generation cycle.</p><p>Once the termination criterion (the number of generations for instance) is met with, extract the optimal buy/sell weights from the individual in the Hall of Fame. Compute the rebalanced weights using equation (4).</p><h4><strong>Output</strong></h4><p>It can be verified that the optimal buy/sell weights and the rebalanced weights satisfy all the constraints imposed on them, besides delivering a solution with the maximal Sharpe Ratio. Given the mean returns and the covariance of returns, the risk and return of the optimal rebalanced portfolio can be easily computed. It can be verified that the rebalanced portfolio is fully invested, its risk does not exceed that of the original portfolio risk and is a self-financing portfolio.</p><p>(See Sec. 7.3 of Chapter 7, Metaheuristic Portfolio Rebalancing with Transaction Costs [PAI 2018] to know about the design, process flow chart and execution of Evolution Strategy with Hall of Fame for a portfolio rebalancing model with a different objective function, though.)</p><h3><strong>9. Case Study</strong></h3><p>We proceed to demonstrate the portfolio rebalancing model over an equity portfolio invested in <strong>S&amp;P BSE200 (Bombay Stock Exchange, India)</strong> markets. The historical data set for the period (April 2009- Jan 2021) encompassing all phases of the Covid-19 crisis period in India, has been considered for the demonstration of the model.</p><h4><strong>9.1 Investing in the portfolio</strong></h4><p>To keep the narrative short, we assume that the investor has already made a <em>technically diverse choice of assets in the portfolio </em>(a <strong><em>k-portfolio,</em></strong> in fact) and had invested in it on April 02, 2019. The historical data set for the period April 01, 2009 to April 01, 2019 was considered to compute the mean returns <em>μ</em> and the variance-covariance matrix of returns <em>V</em>.</p><p>Note that a <strong><em>k-portfolio</em></strong> is an outcome of a <strong><em>heuristic portfolio selection strategy,</em></strong> where the universe of stocks is grouped into clusters that display <strong><em>intra-class similarity</em></strong> and <strong><em>inter-class dissimilarity</em></strong> with regard to the mean-returns and covariance of returns. Since assets belonging to a cluster are similar in behavior, the investor now makes a choice of one asset each from each cluster to ensure <strong><em>diversification of assets in the portfolio</em></strong>. A clustering technique such as <strong><em>k-means algorithm</em></strong> can be used to group the stock universe into <em>k</em> clusters with the investor exercising the choice of <em>k</em>.</p><p>(See <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb">https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb </a>and Chapter 3 Heuristic Portfolio Selection [PAI 2018], to know more about the construction of <em>k</em>-portfolios and their merits)</p><p>The <em>k-portfolio</em> selected by the investor comprised the following 30 assets, after making a heuristic portfolio selection for <em>k = 30</em>:</p><p>3MIndia Ltd. [“‘3MINDIA’”], Ashok Leyland Ltd.[“‘ASHOKLEY’”], Bajaj Finance Ltd. [“‘BAJFINANCE’”], Bharat Forge Ltd. [“‘BHARATFORG’”], GAIL (India) Ltd. [“‘GAIL’”], GMR Infra Ltd. [“‘GMRINFRA’”], HDFC Bank Ltd.[“‘HDFCBANK’”], Hindustan Petroleum Corporation Ltd. [ “‘HINDPETRO’”], Indian Oil Corporation Ltd.[ “‘IOC’”], ITC Ltd. [“‘ITC’”], Jindal Steel Ltd. [“‘JINDALSTEEL’”], JSW Steel Ltd.[ “‘JSWSTEEL’”], Jubilant Life Sciences Ltd.[“‘JUBILANT’”], Larsen and Toubro Ltd. [“‘LT’”], Mahindra and Mahindra Ltd., [“‘M&amp;M’”], MindTree Ltd.[“‘MINDTREE’”], NMDC LTD. [“‘NMDC’”], Power Finance Corporation Ltd. [“‘PFC’”], Rajesh Exports Ltd. [“‘RAJESHEXPO’”], Relaxo FootWears Ltd. [“‘RELAXO’”], Reliance Industries Ltd. [“‘RELIANCE’”], State Bank of India Ltd. [“‘SBIN’”], Shree Cement Ltd. [“‘SHREECEM’”], Tata Steel Ltd. [“‘TATASTEEL’”], Tata Consultancy Services Ltd. [“‘TCS’”], UltraTech Cement Ltd. [“‘ULTRACEMCO’”], Voltas Ltd. [“‘VOLTAS’”], Wipro Ltd. [“‘WIPRO’”]</p><p>The characteristics of the original portfolio invested in are as shown in Fig. 1. The investor had imposed a bounds constraint of investing at least 1% of the capital in all the assets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*qR2kJOJlt2eBaQ16T5BMxA.png" /><figcaption>Fig. 1 Characteristics of the original S&amp;P BSE200 equity portfolio invested on April 02, 2019</figcaption></figure><h4><strong>9.2 Untended Portfolio</strong></h4><p>The portfolio was kept untended from April 03, 2019 to May 31, 2020, which included periods of long spells of lockdown and partial lockdown in India ordered by the Central and State Governments, to tackle the pandemic crisis.</p><h4><strong>9.3 Portfolio Rebalancing</strong></h4><p>The portfolio was rebalanced on June 02, 2020.</p><p>To undertake this and implement the portfolio rebalancing model described by equations (8) and (2–6), the historical data set from April 01, 2009 to June 01, 2020 for the stocks invested in the portfolio were considered. The mean returns and the variance-covariance matrix of returns were computed. The weights <em>W </em>of the original portfolio and its risk <em>Risk{Original}</em> were also input, along with the other parameters of the portfolio as explained in Section 6, to the ES HOF model.</p><p>A fragment of the CSV file <strong>S&amp;PBSE200_kPortfolioRebal.csv</strong>, which describes the asset labels, mean returns and variance-covariance matrix of returns for the historical period concerned, to be used by ES HOF for the construction of optimal rebalanced portfolio is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*Y8cjzbL1PmcBgpjxKDCEIg.png" /><figcaption>Fig. 2 Structure of the input CSV file, which describes the asset labels, mean returns and variance-covariance matrix of returns for the historical period concerned, to be used by ES HOF for the construction of optimal rebalanced portfolio</figcaption></figure><h3>10. Software implementation of ESHOF for Optimal Portfolio Rebalancing</h3><p>The ES HOF program is a conglomeration of functions typical of any metaheuristic strategy. The Python implementation of the strategy can be freely downloaded from the following site:</p><h3>Python code:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/75/0*T0C17qzAP9gZE-f3.png" /></figure><p><a href="https://github.com/PaiViji/PythonFinance--Portfolio-Rebalancing-using-Metaheuristics">Python code for Optimal Portfolio Rebalancing</a></p><p>Download Jupyter Notebook in Python: “<a href="https://github.com/PaiViji/PythonFinance--Portfolio-Rebalancing-using-Metaheuristics/blob/main/MainContent.ipynb"><strong>MainContent.ipynb</strong></a>”</p><p>The Python code is demonstrated over the S&amp;PBSE200 equity portfolio discussed in this post.</p><p>Needless to say, users need to provide appropriate portfolio parameters and ES HOF control parameters as inputs, while re-using or replicating ES HOF for optimal rebalancing of their portfolios.</p><h3>11. Optimal Rebalanced Portfolios — Analysis of Results</h3><h4><strong>11.1 Characteristics of the Optimal Rebalanced Portfolio</strong></h4><p>Typical of metaheuristic strategies, ES HOF yields multiple optimal solutions during its various runs. The interpretation of the results obtained by ES HOF during one of its runs, is shown in Fig. 3.</p><p>The optimal buy/sell /hold weights obtained by ES HOF (buy shown in muted green, sell shown in muted orange and hold shown in yellow) and the corresponding rebalanced portfolio weights have been shown in the figure. The Sharpe Ratios, Annualized Risk(%) and Expected Portfolio Annualized Return(%) of the original and rebalanced portfolios have also been listed.</p><p>It can be seen that the risk of the optimal rebalanced portfolio does not exceed that of the original portfolio’s.</p><p>The rebalanced portfolio now comprises only 17 assets from out of 30 assets invested in the original portfolio. It can be seen in Fig. 3 that the assets [ASHOKLEY], [BHARATFORG], [GAIL], [GMRINFRA], [IOC], [JINDALSTEL], [JSWSTEEL], [LT], [M&amp;M], [NMDC], [PFC],[SBIN], [TATASTEEL] have been divested of during optimal rebalancing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*miMEWN8QeoUlG5olgzJfrg.png" /><figcaption>Fig. 3 Characteristics of the rebalanced portfolio (rebalanced on June 02, 2020) as compared with those of the original portfolio (invested on April 02, 2019) kept untended up till June 01, 2020.</figcaption></figure><h4><strong>11.2 Multiple Solutions — Making a Choice!</strong></h4><p>It needs to be emphasized that due to the stochastic behavior of exploring solutions over large search spaces by generating a random population of individuals, which evolve over the generations into optimal solutions, metaheuristic strategies are endowed with inherent capabilities to deliver multiple solutions that are either optimal or acceptable or near-optimal. Thus metaheuristic strategies generate multiple solutions to the problem in hand for various runs. This characteristic of metaheuristic algorithms needs to be viewed meritoriously and exploited to one’s own advantage.</p><p>Table 1 shows the summarized characteristics of optimal rebalanced portfolios delivered by ES HOF during various runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ikmrn65ORMnbbyN7mP3R4w.png" /><figcaption>Table 1 Summarized characteristics of optimal rebalanced portfolios of S&amp;PBSE200 index obtained by ES HOF</figcaption></figure><h4><strong>11.3 Convergence Characteristics of ES HOF</strong></h4><p>Observing the convergence behavior of metaheuristic algorithms is an essential part of the study. A distribution based criterion viz., P Measure [FEO 2006] has been employed to observe the convergence behavior of ES HOF. <br>The generation number and P Measure value of the new generation population, comprising the best fit parent and offspring chromosomes, has been recorded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*33tHFRfJYLnLq_3Gcb-KZg.png" /><figcaption>Fig. 4 Convergence of ES HOF during sample runs</figcaption></figure><p>Fig. 4 illustrates the trace of the P Measure values during the generation cycles of a few sample runs. It can be observed that P Measure values of ES HOF in a matter of 200~300 generations, have begun converging towards 0, indicating faster and better convergence.</p><h4><strong>11.4 Relentless Rebalancing!</strong></h4><p>The S&amp;PBSE200 index portfolio rebalanced on June 02, 2020 by ES HOF resulted in a portfolio comprising 17 assets. This portfolio was kept untended until Jan 26 2021 and rebalanced again on Jan 27 2021 using ES HOF. Fig 5 illustrates the optimal buy/sell weights, the rebalanced weights, the Sharpe Ratio, the annualized risk(%) and the expected portfolio annualized return(%) of the rebalanced portfolio by ES HOF.</p><p>It can be observed that the optimal rebalanced portfolio satisfies all the constraints imposed on it.</p><p>The muted green cells indicate “buy stock”, muted orange cells indicate “sell stock” and the yellow cells indicate “hold stock” decisions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ORF26GjqwmUBkSOZv5HEpg.png" /><figcaption>Fig. 5 Characteristics of the rebalanced portfolio (rebalanced on Jan 27, 2021) as compared with those of the already once rebalanced portfolio (rebalanced on June 02, 2020) and kept untended until Jan 26, 2021</figcaption></figure><h3><strong>12. Conclusion</strong></h3><p>This work demonstrates how a metaheuristic strategy (ES HOF) is able to obtain optimal rebalanced portfolios. An S&amp;P BSE200 equity portfolio invested on April 02, 2019 and kept untended up till June 01, 2020 due to the pandemic, was rebalanced on June 02, 2020. Again, the rebalanced portfolio was kept untended up till Jan 26, 2021 and rebalanced again on Jan 27, 2021. It can be observed that ES HOF was able to obtain optimal rebalanced portfolios that satisfied all the constraints imposed on it by the investor. The buy/sell/hold decisions put forth by ES HOF satisfied their respective constraints and the risk of the rebalanced portfolio did not exceed that of the original portfolio as well.<br> <br>At this juncture, it pays to recall Qian’s [QIA 2014] intriguing question “To rebalance or not to rebalance?” and the significant assertions that he made in this regard. Sec. 7.5.2 of Chapter 7 Metaheuristic Portfolio Rebalancing with Transaction Costs [PAI 2018] details investigation of Qian’s assertions on a high risk portfolio invested in S&amp;P BSE 200 equity index.</p><h3>Companion Reading</h3><p>[1] Chapter 2 A Brief Primer on Metaheuristics [PAI 2018]</p><p>[2] MATLAB Demonstration of <a href="https://in.mathworks.com/matlabcentral/fileexchange/64507-metaheuristic-portfolio-optimization-models">Metaheuristic Portfolio Rebalancing with Transaction Costs in MathWorks Central File Exchange</a></p><p>[3] <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson6_SharpeRatioOptimization/Lesson6_MainContent.ipynb">Sharpe Ratio based Portfolio Optimization</a><br> <br>[4] <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb">Heuristic Portfolio Selection</a></p><p>[5] <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson1_FundaRiskReturnPortfolio/Lesson1_MainContent.ipynb">Fundamentals of Risk and Return of a Portfolio</a></p><h3>References</h3><p>[FEO 2006] Feoktistov V, “Differential Evolution in search of solutions”, Springer, 2006.</p><p>[JOI 1994] Joines J A and C R Houck, “On the use of non-stationary penalty functions to solve nonlinear constrained optimization problems with GAs”, Proceedings of the First IEEE Conference on Evolutionary Computation, pp.579–584, 1994.</p><p>[PAI 2018] Vijayalakshmi Pai G. A., “<a href="https://www.mathworks.com/academia/books/metaheuristics-for-portfolio-optimization-pai.html">Metaheuristics for Portfolio Optimization- An Introduction using MATLAB</a>”, Wiley-ISTE, 2018.</p><p>[QIA 2014] Qian E E, “To rebalance or not to rebalance: A statistical comparison of terminal wealth of fixed weight and buy-and-hold portfolios”,<br><a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2402679">https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2402679</a>, Jan 26, 2014.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d166787712b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Risk-Budgeted Portfolios- Mulling Risk to Multiply Returns!]]></title>
            <link>https://medium.com/@pai.viji/risk-budgeted-portfolios-mulling-risk-to-multiply-returns-3a0151e8f563?source=rss-479eaa23ba8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a0151e8f563</guid>
            <category><![CDATA[risk-budgeting]]></category>
            <category><![CDATA[differential-evolution]]></category>
            <category><![CDATA[metaheuristics]]></category>
            <category><![CDATA[sharpe-ratio]]></category>
            <category><![CDATA[portfolio-optimisation]]></category>
            <dc:creator><![CDATA[Vijayalakshmi Pai]]></dc:creator>
            <pubDate>Wed, 26 Aug 2020 05:41:55 GMT</pubDate>
            <atom:updated>2020-08-26T07:27:55.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XvpWO-Ty7FP5vfjPIZO1gg.png" /><figcaption>Risk Budgeted Portfolios — Braving risk to earn the honey pot?</figcaption></figure><h3><strong>1. Introduction</strong></h3><p>“<em>Higher the risk, greater the probability of return and lower the risk, smaller the probability of return</em>”, is a well-known adage in investment science. This trade off between risk and return that investors confront in the course of their investment decisions, is what is termed as “<strong>Risk-Return Tradeoff</strong>” in portfolio theory.</p><p><em>Modern Portfolio Theory</em> (MPT) pioneered by Harry Markowitz in his paper on “Portfolio Selection” [MARK 1952] and for which he was awarded the Nobel Prize, chose to tackle the risk-return tradeoff by modelling a portfolio investment decision problem as a <em>bi-objective optimisation</em> problem of <strong>maximizing expected portfolio return</strong> and <strong>minimizing portfolio risk</strong>.</p><p>Thus, minimizing risk is undoubtedly a pre-dominant objective in investment decision making. Nevertheless, the hard reality of practitioners and fund managers for example, having to take risks to enable their portfolios out beat <em>benchmarks </em>cannot be sidelined<em>. </em>In practice, fund managers are mandated to accommodate allowable risks in their portfolios relative to the benchmarks (known as <em>Tracking Error</em> or <em>Active Risk</em>), to enable them mimic or beat the bench marks to earn more returns.</p><p>So, warming up before a fire?</p><p>Get too close, flammable!-Move too far, futile!</p><p>Now, what is the way?</p><p><strong>Risk Budgeting</strong> also referred to as <strong>Risk Decomposition</strong> or <strong>Risk Contribution</strong> is an investment strategy where portfolio risk is distributed across assets or asset classes in the portfolio, ensuring exposure to investment risk as well as market protection at the same time. This is effected by imposing limits on the individual risks of the assets or asset classes comprising the portfolio and ensuring that the <em>asset allocation is done in strict compliance to the risk limits imposed</em>.</p><p><strong>Risk-Budgeted portfolios </strong>can be <em>long-short portfolios </em>or <em>long-only</em> portfolios, with or without <em>leveraged bounds</em>, spread across <em>uni or multi asset classes</em>, as dictated by the investor’s preferences, risk appetites and market ecosystem.</p><h3>2. Risk-Budgeted Portfolio Construction</h3><p>Let us consider an investor who desires to construct a <strong>leveraged long-short Risk-Budgeted portfolio</strong>, optimal with regard to an objective function and subject to constraints that reflect restrictions on asset allocation and the investor’s preferences.</p><p>(1) The objective is to <strong>maximize Sharpe Ratio</strong> of the portfolio.</p><p>(See <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson6_SharpeRatioOptimization/Lesson6_MainContent.ipynb">Lesson 6 Sharpe Ratio Optimization</a> to know about Sharpe Ratio based portfolio optimization)</p><p>The following <strong>constraints</strong> are imposed on the portfolio by the investor:</p><p>(2) A <em>budget constraint on the portfolio</em>, where the capital is <em>fully invested</em> (i.e.) the sum of the portfolio weights equals 1.<br> (3) <em>Leveraged bounds of [0.001, +3]</em> on investor chosen <em>selective</em> <em>long positions in which investment is mandatory. </em><br> (4) <em>Leveraged bounds of [-3, 0]</em> on investor chosen <em>selective</em> <em>short positions in which investment is optional.</em><br> (5) <em>Leveraged bounds of [0, +3]</em> on all <em>other long positions in the portfolio in which investment is optional.</em><br> <br>Here the bounds [-3, +3] are indicative of the fact that the investor is open to leveraging investments in the positions concerned to some extent, not withstanding the fact that the portfolio needs to be a fully invested one (that is, sum of weights equals 1).</p><p>Risk Budgeting is enforced through what is called <strong><em>Marginal Contribution to Risk (MCR)</em></strong> and is defined as the partial derivative of the risk with respect to its weights as given below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*HbZ-URQ8QY8XiCSp0uTsTQ.png" /></figure><p>where vector <em>m</em> denotes the MCR, <em>V</em> is the variance-covariance matrix of asset returns and vector <em>W</em> is the portfolio weight vector.</p><p>The <strong><em>Absolute Contribution to Total Risk</em></strong> is given by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*h5pdgKhGDGLxoHvzCsbQ7A.png" /></figure><p>The <strong><em>Percentage Contribution to Total Risk</em></strong> is given by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*3oCmwWfr4qcb6YQILhJ6Gw.png" /></figure><p>The sum of the Absolute Contribution to Total Risk for a portfolio equals its risk.</p><p>The Risk-Budgeting constraint is defined as,</p><p>(6) <strong>The percentage contribution to risk(%) of the portfolio cannot exceed r%, where r is a risk limit imposed by the investor</strong>.<br> <br>Thus, the objective and constraints of the Risk-Budgeted portfolio optimization model are described by points (1) -(6).</p><h3>3. Mathematical model</h3><p>The mathematical model for Risk-Budgeted portfolio optimization whose objective function and constraints were defined in the previous section, is as shown below:</p><ol><li>Objective function for maximizing Sharpe Ratio of the portfolio</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*bXynpE8eVwnwZQ6z5uRHAQ.png" /></figure><p>subject to the constraints that describe constraints (2)-(6) listed in Sec. 2. viz.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*tmv05xMQIYDHeIBpGC8BzQ.png" /></figure><p>In the above system of equations, vector μ denotes the mean returns of the assets in the portfolio, Rf denotes the risk free rate of return, vector <em>W</em> with superscript <em>Long, Short </em>and <em>Others, </em>indicate the weights of the mandatory long positions, optional short positions and optional long positions to be invested in the optimal portfolio and σP denotes portfolio risk.</p><p>Equations [5] to [8] illustrate the budget and leveraged bound constraints imposed on the long and short positions. Equation [9] denotes the risk budgeting constraint.</p><h3>4. Metaheuristic Solution Strategy</h3><p>We proceed to undertake the optimization of the model described by equations [4] to [9] employing a robust <strong>metaheuristic strategy</strong> viz., <strong>Differential Evolution with Hall of Fame (DE HOF)</strong>. DE HOF dynamically arrives at the optimal composition of long and short positions of the portfolio that yield the maximal Sharpe Ratio, subject to all the constraints enforced on the assets and the portfolio.</p><p>(See Chapter 2: A Brief Primer on Metaheuristics [PAI 2018], to know more about metaheuristics and Differential Evolution)</p><p>Metaheuristic strategies build <strong>feasible solution sets</strong> that satisfy the constraints imposed, during the course of their execution process. However <strong>constraint handling</strong><em> </em>has been a major problem in the application of metaheuristic strategies to complex constrained optimization problems, to tackle which several methods such as <strong>Penalty Function Strategy</strong> and <strong>Repair Strategy</strong> have been proposed.</p><p>For the Risk Budgeted portfolio optimization model, DE HOF makes use of Joines and Houck’s <em>Dynamic Penalty Function Strategy</em> [JOI 1994] to handle the Risk Budgeting constraint (equation [9]) and Repair Strategies to handle the budget constraint on the portfolio and the leveraged bounds constraints on the long /short positions (equations [5] to [8]).</p><p>Repair strategies yield feasible solution sets and therefore foster exploration of optimal solutions in the feasible solution space, leading to faster convergence of the metaheuristic method. However, constructing a repair strategy to tackle the constraints defined for the problem in hand can be difficult, but once accomplished, can make a world of a difference to the evolution process during the search for solutions.</p><p>(See Sec. 4.5 of Chapter 4: Metaheuristic Risk-Budgeted Portfolio Optimization [PAI 2018], to know about the Repair Strategies evolved for the Risk-Budgeted portfolio optimization model)</p><h3>5. Transformation of the Mathematical Model</h3><p>Joines and Houck’s dynamic penalty function strategy is used to tackle the Risk Budgeting constraint represented by equation [9]. The constraint is accommodated in the “penalized” objective function by defining appropriate penalty functions. The transformed mathematical model is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*GXYlLfJbStw2enrVZvolig.png" /></figure><p>In the system of equations [11], (C,α,β) are all constants and <em>t</em> is the generation count of the metaheuristic strategy DE HOF.</p><p>DE HOF now strives to solve the optimization model whose penalized objective function is described by equations [10]-[11] subject to the budget and leveraged bounds constraints imposed on the long and short positions of the portfolio, described by equations [5]-[8] only.</p><h3>6. Differential Evolution with Hall of fame — a brief round up</h3><p>DE HOF is a population based metaheuristic strategy that can efficiently solve optimization problems with complex constraints. We restrict the discussion to the DE HOF designed to solve the Risk-Budgeted portfolio optimization problem model. The input, process and output of the DE HOF strategy are as follows:</p><h4>Inputs</h4><p>Before the optimization process is initiated, the following inputs should be made ready: (1) <em>Portfolio parameters</em> and (2) <em>Control parameters of DE HOF strategy.</em></p><p>The portfolio parameters are (i) asset labels (ii) mean asset returns (daily %)(iii) variance-covariance matrix of returns (iv) risk limit r% and (v) risk free rate of return.</p><p>The DE HOF parameters are (i) population size (ii) number of generations (iii) dynamic penalty function parameters <em>(C, α, β)</em> (iv) Scale factor <em>βs</em> and (v) probability of recombination <em>Pr</em>.</p><h4>Process</h4><p>DE HOF initiates its evolutionary process by first generating an <em>initial random population of individuals</em> that represent the candidate solution sets to the optimization problem concerned. Each individual (or chromosome) in the population represents a collection of N <em>genes (or components)</em>that represent random weights generated in the range [-3, +3] for the N assets in the portfolio. For the defined Risk-Budgeted portfolio optimization problem, the investor has set the leveraged bounds for the weights to shuttle between -3 and +3.</p><p>Each individual in the candidate solution set is repaired with the help of the repair strategies formulated for the constraints concerned, yielding a feasible solution set that satisfies constraints represented by equations [5] to [8]. This population is termed as <em>parent population.</em></p><p>DE HOF now computes the <em>fitness function values</em> for each individual in the parent population, making use of the penalized objective function described by equations [10]-[11].</p><p>Making use of mutation and crossover operators (<em>Binomial Crossover operator</em>) and the scale factor, DE HOF generates what are called <em>trial vectors</em> which eventually leads to the production of the <em>offspring population</em> of individuals.</p><p>The offspring population of individuals is transformed into a feasible solution set by calling the repair strategies to work over them. The fitness function values of the feasible offspring population are computed.</p><p>Based on the fitness function values of the individuals in the parent population and offspring population, the best fit individuals are selected using the <em>Deterministic Selection operator</em> and pushed to the next generation. The best among the better individuals selected for the next generation with maximal fitness function value and zero penalty function value (no constraints violated) is inducted into the <strong>Hall of Fame</strong>.</p><p>The population of individuals pushed to the next generation are set as the parent population for the second generation. The second generation offspring population is now generated by repeating the reproduction process. The better individuals of the second generation parent and offspring populations are selected for the third generation. The best among the better individuals selected for the third generation, competes with the individual in the Hall of Fame. DE HOF ensures that only the best individual by way of maximal fitness function value and zero penalty function value generated this far, is inducted into the Hall of Fame.</p><p>Thus, the generation cycles progress, one after another, until the termination criterion is met with, at which stage that individual in the Hall of Fame is declared to be the optimal solution to the problem concerned.</p><h4>Output</h4><p>The genes or components of the HOF individual represent the optimal weights or proportion of capital to be invested in the long/short positions of the portfolio. Positive weights indicate assets that are to be longed and negative weights indicate assets that are to be shorted. Given the mean returns and the covariance of returns, the risk and return of the optimal Risk-Budgeted portfolio can be easily computed. It can be verified that the portfolio is fully invested and all the long and short positions in the optimal portfolio satisfy their respective bounds constraints and the percentage contribution to risk of the portfolio lies within the stipulated risk limits.</p><p>(See Sec. 4.6 of Chapter 4 Metaheuristic Risk-Budgeted Portfolio Optimization [PAI 2018] to know more about the design, process flow chart and execution of Differential Evolution with Hall of Fame based Risk-Budgeted Portfolio construction)</p><h3>7. Case Study</h3><p>We proceed to demonstrate the construction of Risk-Budgeted long-short portfolios over S&amp;P BSE200 index (April 2009- July 2020, Bombay Stock Exchange, India) with the historical data set spanning the period between “postpartum (2008) depression” and mid Covid-19 crisis(in India of course!).</p><p>To keep the story short, we assume that the investor has already made a <em>technically diverse choice of assets in the portfolio</em> (a <strong><em>k</em>-portfolio</strong>, in fact) and is ready with the mean returns μ and the variance-covariance matrix of returns V.</p><p>Note that a <em>k-portfolio</em> is an outcome of a <strong>heuristic portfolio selection strategy</strong>, where the universe of stocks is grouped into clusters that display <em>intra-class similarity</em> and <em>inter-class dissimilarity</em> with regard to the mean-returns and covariance of returns. Since assets belonging to a cluster are similar in behavior, the investor now makes a choice of one asset each from each cluster to ensure <em>diversification of assets in the portfolio</em>. A clustering technique such as <em>k-means algorithm </em>can be used to group the stock universe into <em>k</em> clusters with the investor exercising the choice of <em>k</em>.</p><p>(See <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb">Lesson 3 Heuristic Portfolio Selection </a>and Chapter 3 Heuristic Portfolio Selection[PAI 2018], to know more about the construction of <em>k</em>-portfolios and their merits)</p><p>Let the <em>k</em>-portfolio selected by the investor comprise the following 30 assets, after making a heuristic portfolio selection for <em>k = 30</em>:</p><p>Adani Enterprises Ltd. [“‘ADANIENT’”], Astral Poly Technik Ltd. [“‘ASTRAL’”], Bajaj Finance Ltd.[“‘BAJFINANCE’”], Bharat Forge Ltd. [“‘BHARATFORG’”], Bharat Petroleum Corp Ltd. [“‘BPCL’”], Cholamandalam Investment and Fin Co Ltd. [“‘CHOLAFIN’”], Dabur India Ltd[“‘DABUR’”], GAIL (India) Ltd. [“‘GAIL’”], HDFC Bank Ltd.[“‘HDFCBANK’”], Hindustan Petroleum Corporation Ltd. [ “‘HINDPETRO’”], Vodafone Idea Ltd. [“‘IDEA’”], Indusind Bank Ltd. [“‘INDUSINDBK’”], Indian Oil Corporation Ltd.[ “‘IOC’”], ITC Ltd. [“‘ITC’”], JSW Steel Ltd.[ “‘JSWSTEEL’”], Jubilant Life Sciences Ltd.,[“‘JUBILANT’”], Larsen &amp; Toubro Ltd.[“‘LT’”], MindTree Ltd. [“‘MINDTREE’”], Mahindra &amp;Mahindra Ltd. [“‘M&amp;M’”], Nestle India Ltd. [“‘NESTLEIND’”], NMDC Ltd. [“‘NMDC’”], Petronet LNG Ltd. [“‘PETRONET’”], REC Ltd. [“‘RECLTD’”], Relaxo Footwears Ltd. [“‘RELAXO’”], State Bank of India Ltd. [“‘SBIN’”], Sun Pharmaceutical Industries Ltd. [“‘SUNPHARMA’”], Tata Motors Ltd. [“‘TATAMOTORS’”], Tata Consultancy Services Ltd. [“‘TCS’”],Whirlpool of India Ltd. [“‘WHIRLPOOL’”], Wipro Ltd. [“‘WIPRO’”]</p><p>The objective is to construct a Risk-Budgeted portfolio that will yield maximal Sharpe Ratio subject to the constraints listed in equations [5]-[9] for a risk budget <em>r</em>=12.5%.</p><p>A fragment of the CSV file which describes the asset labels, mean returns and variance-covariance matrix of returns, to be used by DE HOF for the construction of optimal Risk-Budgeted portfolio is shown in Fig. 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yPTH0j080FVvXHfDaefEBQ.png" /><figcaption>Fig. 1 Structure of the input file to DE HOF that captures details about assets in the portfolio, their mean and covariance of returns (daily %)</figcaption></figure><h3>8. Software Implementation of DE HOF for Risk-Budgeted Portfolio Construction</h3><p>The DE HOF program is a conglomeration of functions typical of any metaheuristic strategy. The Python and MATLAB implementations of the strategy can be freely downloaded from the following sites:</p><h3>Python code:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/75/0*Xswdhay4CywD3YMR.png" /></figure><p><a href="https://github.com/PaiViji/PythonFinance--RiskBudgeted-Portfolio-Construction">Python code for Risk-Budgeted Portfolio Construction</a></p><p>Download Jupyter Notebook in Python: “<a href="https://github.com/PaiViji/PythonFinance--RiskBudgeted-Portfolio-Construction/blob/master/MainContent.ipynb"><strong>MainContent.ipynb</strong></a>”</p><p>The Python code is demonstrated over the S&amp;PBSE200 equity portfolio discussed in this post.</p><h3>MATLAB code:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/86/0*SG4iS_LpT2Uoqq7K.png" /></figure><p><a href="https://in.mathworks.com/matlabcentral/fileexchange/64507-metaheuristic-portfolio-optimization-models">MATLAB Code for Risk-Budgeted Portfolio Construction using DE HOF</a></p><p>Download from the Mathworks Central File Exchange: “<strong>Chapter4_RiskBudgetPortfolioOptmzn_DEHOF.m</strong>”</p><p>The MATLAB code is demonstrated over a global portfolio of equity indices, bonds, currencies and commodities discussed in Chapter 4 of [PAI, 2018].</p><p>Needless to say, users need to provide appropriate portfolio parameters and DE HOF control parameters as inputs, while re-using or replicating DE HOF for the construction of their own Risk-Budgeted leveraged long-short portfolios.</p><h3>9. Risk-Budgeted Portfolio — Analysis of Results</h3><p>Typical of metaheuristic strategies, DE HOF yields multiple optimal solutions during its various runs, some of which are near-optimal or acceptable.</p><p>It needs to be emphasized that population based metaheuristic algorithms display stochastic behavior, since a random population of individuals explore large search spaces and evolve over generations into optimal solutions. These strategies therefore, unlike traditional methods, are endowed with an inherent capability to deliver multiple solutions that are either optimal or acceptable or near-optimal. This characteristic of metaheuristic algorithms needs to be viewed meritoriously and exploited to one’s own advantage.</p><p>Thus in the case of multiple “optimal” portfolio allocations that are attainable, a discerning investor can now make a judicious choice of that optimal allocation that best suits his or her investment sentiments, risk appetites etc.</p><p>Let us have a peek at two optimal portfolios, termed Portfolio A and Portfolio B for ease of reference, delivered by DE HOF during two of its runs. They are seemingly “near-optimal” but given the fact that the asset allocation, risk, expected return and Sharpe Ratios are known prior, it is left to the investor to make an appropriate choice.</p><h4>9.1 Portfolio A</h4><p>Maximal Sharpe Ratio: 2.28 <br>Annualized Risk(%): 21.5 <br>Expected Portfolio Annualized Return(%): 55.6<br>Leveraged allocation on Long Positions: 129%<br>Leveraged allocation on Short Positions: 29%</p><p>Fig. 2(a) and Fig. 2(b) illustrate the asset allocation of the optimal risk budgeted long-short portfolio. Fig. 2(c) illustrates the percentage contribution to risk of the portfolio.</p><p>It can be observed that Portfolio A reports a high Sharpe Ratio with low risk and could be opted for by a moderately risk-aggressive investor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*dbyY1uQAdnm0Fqi_cCOB0w.png" /><figcaption>(a) Portfolio A: Long Positions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*K2nSFoOkFDYLw4haEcxZzw.png" /><figcaption>(b) Portfolio A: Short Positions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*4CrVKmSxoyrGkx0wxXTEeA.png" /><figcaption>( c) Portfolio A: Percentage Contribution to Risk (risk limit 12.5%)</figcaption></figure><h4>Fig. 2 Optimal Risk-Budgeted and Leveraged Long-Short Portfolio invested in S&amp;P BSE200 index (Portfolio A) obtained by DE HOF</h4><h4>9.2 Portfolio B</h4><p>Maximal Sharpe Ratio: 1.02 <br>Annualized Risk(%): 68.24 <br>Expected Portfolio Annualized Return(%): 76.22<br>Leveraged allocation on Long Positions: 209%<br>Leveraged allocation on Short Positions: 109%</p><p>Fig. 3(a) and Fig. 3(b) illustrate the asset allocation of the optimal risk budgeted long-short portfolio. Fig. 3(c) illustrates the percentage contribution to risk of the portfolio.</p><p>It can be observed that Portfolio B reports a decently good Sharpe Ratio, but with high risk and high returns and therefore could be opted for by a highly risk aggressive investor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*zwCAZ3DYyFpOeS_IncZLpQ.png" /><figcaption>(a) Portfolio B: Long Positions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*_SdjFHhgDN9--xqH2Bdtfg.png" /><figcaption>(b) Portfolio B: Short Positions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*t57F49HMrIMJZnivnFrUSg.png" /><figcaption>( c) Portfolio B: Percentage Contribution to Risk (risk limit 12.5%)</figcaption></figure><h4>Fig. 3 Optimal Risk-Budgeted and Leveraged Long Short Portfolio invested in S&amp;P BSE200 index (Portfolio B) obtained by DE HOF</h4><h3>10. Conclusion</h3><p>High returns are always accompanied by high risk. Nevertheless, Risk-Budgeting is an investment approach which, while playing with the fire of risk, ensures that it is adequately protected to reap the desired returns. Thus risk budgeting strategies ensure investment exposure and market protection at the same time.</p><p>The risk budgeting approach was demonstrated over an all equity portfolio that is leveraged and long-short. Risk-budgeting can also be employed over leveraged long-short portfolios with multiple asset classes such as equities, bonds, commodities and currencies. A demonstration of risk-budgeting over one such global portfolio with multiple asset classes can be found in Chapter 4 Metaheuristic Risk-Budgeted Portfolio Optimization in [PAI 2018] and [PAI 2011a].</p><p>Risk budgeting approach has also been applied over equity market neutral portfolios, future portfolios and other long-short portfolios [PAI 2012][PAI 2015] and [PAI 2011b].</p><p>Unlike traditional methods, the metaheuristic strategy is inherently endowed with the potential to deliver multiple near-optimal risk-budgeted portfolios, providing investors the luxury of making choices that follow their investment sentiments.</p><h3>Companion Reading</h3><p>[1] Chapter 4 Metaheuristic Risk-Budgeted Portfolio Optimization [PAI 2018]</p><p>[2] Chapter 2 A Brief Primer on Metaheuristics [PAI 2018]</p><p>[3] <a href="https://in.mathworks.com/matlabcentral/fileexchange/64507-metaheuristic-portfolio-optimization-models">MATLAB Demonstration of Risk-Budgeted Portfolio Optimization using DE HOF, in Mathworks Central File Exchange</a></p><p>[4] <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson6_SharpeRatioOptimization/Lesson6_MainContent.ipynb">Sharpe Ratio based Portfolio Optimization </a><br> <br>[5] <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb">Heuristic Portfolio Selection</a></p><p>[6] <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson1_FundaRiskReturnPortfolio/Lesson1_MainContent.ipynb">Fundamentals of Risk and Return of a Portfolio</a></p><h3>References</h3><p>[JOI 1994] Joines J A and C R Houck, “On the use of non-stationary penalty functions to solve nonlinear constrained optimization problems with GAs”, <em>Proceedings of the First IEEE Conference on Evolutionary Computation</em>, pp.579–584, 1994.</p><p>[MARK 1952] Harry Markowitz, “Portfolio Selection”, <em>The Journal of Finance</em>, Vol. 7, No. 1, pp. 77–91, Mar., 1952.</p><p>[PAI 2018] Vijayalakshmi Pai G. A., “<a href="https://www.mathworks.com/academia/books/metaheuristics-for-portfolio-optimization-pai.html"><em>Metaheuristics for Portfolio Optimization- An Introduction using MATLAB</em></a>”, Wiley-ISTE, 2018.</p><p>[PAI 2015] Vijayalakshmi G A and Thierry Michel, “<em>Metaheuristic Construction of Long-Only Risk Budgeted Futures Portfolio with Maximal Diversification Index</em>”, Available at <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2622980">https://papers.ssrn.com/…abstract_id=2622980</a> (Working paper Series), June 25, 2015.</p><p>[PAI 2012] Vijayalakshmi Pai G A and Thierry Michel, “Differential Evolution based Optimization of Risk Budgeted Equity Market Neutral Portfolios”, <em>Proc. IEEE World Congress on Computational Intelligence (IEEE WCCI 2012), 2012 IEEE Congress on Evolutionary Computation</em>, pp. 1888–1895, Brisbane, Australia, June 2012.</p><p>[PAI 2011a] Vijayalakshmi Pai G A and Thierry Michel, “Metaheuristic Optimization of Risk Budgeted Global Asset Allocation Portfolios”, <em>Proc. World Congress on Information and Communication Technologies (WICT 2011)</em>, pp. 154–159, Mumbai, India, Dec. 2011.</p><p>[PAI 2011b] Vijayalakshmi Pai G A and Thierry Michel, “Evolutionary Optimization of Risk Budgeted Long-Short Portfolios”, <em>Proc. IEEE Symposium Series in Computational Intelligence (IEEE SSCI 2011): 2011 IEEE symposium on Computational Intelligence for Financial Engineering and Economics (CIFEr 2011)</em>,pp. 59- 66, Paris, France, April 2011.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a0151e8f563" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[130–30 Portfolios -Leveraging Returns!]]></title>
            <link>https://medium.com/@pai.viji/130-30-portfolios-leveraging-returns-314a9295e1e2?source=rss-479eaa23ba8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/314a9295e1e2</guid>
            <category><![CDATA[sharpe-ratio]]></category>
            <category><![CDATA[metaheuristics]]></category>
            <category><![CDATA[130-30-portfolio]]></category>
            <category><![CDATA[differential-evolution]]></category>
            <category><![CDATA[portfolio-optimisation]]></category>
            <dc:creator><![CDATA[Vijayalakshmi Pai]]></dc:creator>
            <pubDate>Thu, 16 Jul 2020 13:41:01 GMT</pubDate>
            <atom:updated>2020-07-16T13:41:01.713Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*1CostSvpAS2yLNtMDeS5Qw.png" /><figcaption>130–30 Portfolios — Using a small fish to catch a big fish?</figcaption></figure><h4><em>1. </em><strong><em>Introduction</em></strong></h4><p><em>130–30 strategy</em> is a portfolio construction method which ensures investment exposure and market protection at the same time. The strategy adopts <em>leveraging</em> by <strong>shorting poor performing stocks to the tune of 30% of the portfolio value</strong> and diverting the funds <strong>to invest in the long, on better performing stocks to the tune of 130% of the portfolio value</strong>. 130–30 portfolios are therefore leveraged <em>long-short portfolios.</em></p><p>Advocates of long-short portfolio strategies have always argued in favor of these strategies when compared to<em> long-only </em>strategies. Grinold and Kahn [GRI 2000] showed that fully leveraged long-short strategies perform better than long-only strategies when the universe of assets is large, volatility of assets is low or the strategy has high active risk. However, the costs of short sales imposing restrictions on the construction of such portfolios have also been debated by Michaud [MIC 1993] and others.</p><p>Nevertheless, the increasing frustrations over long-only portfolios and the growing popularity of leveraged long-short portfolios, have kept the arguments active and in favor of 130–30 portfolios.</p><p>Andrew Lo and Pankaj Patel [ LO 2007] and Johnson <em>et al.</em>, [JOH 2007] to cite a few, concluded that 130–30 strategy does perform better when compared to their long-only counterparts, since the strategy adds value from both long and short sides.</p><h4><strong>2. 130–30 Portfolio Model</strong></h4><p>Let us consider an investor who desires to construct a 130–30 portfolio, optimal with regard to an objective function and subject to constraints that reflect restrictions on asset allocation and the investor’s preferences.</p><p>(1) The objective is to <strong>maximize Sharpe Ratio</strong> of the portfolio.</p><p>The following constraints are imposed on the portfolio by the investor:</p><p>(2) A budget constraint on the portfolio, where the capital is fully invested, (i.e.) the sum of the portfolio weights equals 1.<br>(3) A budget constraint of 130% on the capital invested in the long positions, which automatically implies a budget constraint of 30% on the capital invested in the short positions of the portfolio.<br>(4) Leveraged bounds for long positions to lie in the interval [0, 1.3]<br>(5) Bounds for short positions to lie in the interval [-0.3,0]<br>(6) Portfolio beta needs to be 1, to ensure that the volatility of the portfolio matches with that of the market.</p><h4><strong>3. Mathematical Model</strong></h4><p>Let us suppose that the investor desires to construct a portfolio P comprising N assets with vector <em>μ</em> denoting the asset returns, vector <em>W </em>denoting the asset weights, <em>V</em> the variance-covariance matrix of asset returns and R<em>f</em> the risk-free rate of return.</p><p>With regard to portfolios with equity stocks, <em>portfolio beta</em> is the weighted sum of the asset betas denoted by vector β, where the weights are represented by the portfolio weights <em>W</em>.</p><p>The mathematical model for the 130–30 strategy based Portfolio Optimization is formulated as,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*JaPHok7DEpkx1Jr9kckBnQ.png" /></figure><p>subject to the constraints of</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*j_DZeomLjQDgumtI8zHgxQ.png" /></figure><p>where, following long-short portfolio norms, W+ denotes positive weights which describe the asset allocations on long positions and W- denotes negative weights which describe the asset allocations on short positions in the portfolio.</p><h4>3.1 Long-Plus-Short Portfolio vs Integrated Long-Short Portfolio</h4><p>The 130–30 portfolio model discussed here, is not a mere combination of a <em>long-only portfolio</em> with a <em>short-only portfolio</em>, where the investor earmarks some positions in the portfolio to be longed and the rest to be shorted. Jacobs <em>et al.</em>, [JAC 1999] were critical of this approach and while terming it as a <em>long-plus-short</em> portfolio, asserted that such a portfolio has lesser merits when compared to a real <em>long-short portfolio</em> that undertakes an <em>integrated combination of long and short positions</em>. They claimed that a long-short portfolio construction is not a two-portfolio strategy but <em>“…a one-portfolio strategy in which the long and short positions are determined jointly within an optimization that takes into account the expected returns of the individual securities, the standard deviation of those returns and the correlations between them, as well as the investor’s tolerance for risk”</em> [JAC 1999].</p><p>The strategy adopted to construct such a long-short 130–30 portfolio is evolved using <strong>metaheuristics</strong>. The metaheuristic strategy undertakes an <strong>integrated optimization</strong> of the assets in the portfolio to determine the long and short positions of the portfolio that yield maximal Sharpe Ratio, subject to all the inherent constraints laid down by the investment strategy as well as the investor.</p><h4>4. Metaheuristic Solution Strategy</h4><p>We proceed to undertake the integrated optimization of the 130–30 portfolio model described by equations [1.1] to [1.6] employing a robust <strong>metaheuristic strategy</strong> viz., <strong>Differential Evolution with Hall of Fame (DE HOF)</strong>. DE HOF dynamically arrives at the optimal composition of long and short positions of the portfolio that yield the maximal Sharpe Ratio, subject to all the constraints enforced over the assets and the portfolio.</p><p>(See Chapter 2: A Brief Primer on Metaheuristics [Pai 2018], to know more about metaheuristics and Differential Evolution strategy)</p><p>Metaheuristic strategies build <em>feasible solution sets</em> that satisfy the constraints imposed, during the course of their execution process. However <em>constraint handling</em> has been a major problem in the application of metaheuristic strategies to complex constrained optimization problems, to tackle which several methods such as <em>Penalty Function Strategy</em> and <em>Repair Strategy</em> have been proposed.</p><p>For the 130–30 portfolio optimization, DE HOF makes use of Joines and Houck’s <em>Dynamic Penalty Function Strategy</em> [JOI 1994] to handle the portfolio beta constraint (equation [1.6]) and Repair Strategies to handle the budget constraints on the portfolio and long positions as well as the bounds constraints on the long and short positions (equations [1.2] to [1.5]).</p><p>Repair strategies are custom made to suit the requirements of the problem and evolving such a strategy that will help satisfy one or more constraints at one go, can turn out to be difficult. Nevertheless, once the strategy is evolved, it can help churn out populations of feasible solution sets during each generation cycle of the metaheuristic strategy, leading to faster convergence of the algorithm.</p><p>(See Sec. 6.4.2 of Chapter 6: Metaheuristic 130–30 Portfolio Construction [PAI 2018], to know about the Repair Strategies evolved for the 130–30 portfolio optimization model discussed in this post)</p><h4>5. Transformation of the Mathematical Model</h4><p>Joines and Houck’s dynamic penalty function strategy is used to tackle the portfolio beta constraint represented by equation [1.6]. The portfolio beta constraint is accommodated in the <em>“penalized” objective function</em> by defining appropriate penalty functions. The transformed mathematical model is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*G1orBP4h57Ky-CWrMZlUXQ.png" /></figure><p>where function <em>ψ </em>is the <em>constraint violation function</em> that tackles the portfolio beta constraint using dynamic penalty functions and is defined as,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*4D0r6niu_fdGnsOPf4Kqkw.png" /></figure><p>In the system of equations [1.8], (C, α, β) are constants, <em>t</em> is the generation count, <em>ε </em>is the tolerance limit and function <em>φ </em>tackles the portfolio beta constraint for the tolerance limit<em> ε.</em></p><p>DE HOF now strives to solve the optimization model whose penalized objective function is described by equations [1.7]-[1.8] subject to the budget and bounds constraints imposed on the long and short positions of the portfolio, described by equations [1.2]-[1.5] only.</p><h4>6. Differential Evolution with Hall of Fame — a Brief Roundup</h4><p>DE HOF is a <em>population based metaheuristic strategy </em>that employs the genetic inheritance operators of <em>reproduction</em>, <em>crossover, mutation, selection</em> and /or their variants, to efficiently solve complex constrained optimization problems. DE HOF strategies can help find near-optimal or acceptable solutions, if not optimal solutions, to complex problems when traditional methods find it difficult to solve such problems.</p><p>We restrict the discussion to the DE HOF strategy designed to solve the 130–30 portfolio optimization problem model. The input, process and output of the DE HOF strategy are as follows:</p><h4>Inputs</h4><p>It is essential that the <em>portfolio parameters</em> and the <em>DE HOF strategy parameters</em> are clearly set before the optimization process begins.</p><p>The portfolio parameters are (1) assets comprising the portfolio (2) asset betas (3) mean asset returns (daily %)(4) covariance of returns (the variance-covariance matrix of returns) and (5) risk free rate of return .</p><p>The DE HOF control parameters are (1) population size (2) number of generations (3) dynamic penalty function parameters (4) Scale factor and (5) probability of recombination.</p><h4>Process</h4><p>DE HOF begins its execution by generating an <em>initial random population of individuals</em> that represent the <em>candidate solution sets</em> to the optimization problem concerned. Each individual in the population denotes a collection of N <em>genes</em> that represent random portfolio weights generated in the range [-0.3, 1.3] for the N assets in the portfolio.</p><p>The candidate solution sets are transformed into feasible solution sets by calling the weight repair strategies, which repair each individual in the population, so that it satisfies constraints represented by equations [1.2] to [1.5]. At the end of the process, the initial population is transformed into a population that is a feasible solution set and is termed as the <em>parent population.</em></p><p>Typical of metaheuristic strategies, DE HOF now computes the <em>fitness function values</em> of each individual in the parent population making use of the penalized objective function described by equations [1.7]-[1.8].</p><p>Making use of mutation and crossover operators (<em>Rand4/Best/Dir5 mutation operator</em> and <em>Binomial Crossover operator</em>) and the scale factor, DE HOF generates what are called <em>trial vectors,</em> which eventually leads to the production of the <em>offspring population</em> of individuals. (See [FEO 2006] to know more about Rand4/Best/Dir5 operator and Binomial Crossover operator)</p><p>The offspring population of individuals is standardized to satisfy the respective constraints, by calling the weight repair strategies once again and their fitness function values are computed as was done for the parent population.</p><p>Based on the fitness function values of the individuals in the parent population and offspring population, the best fit individuals are selected using the <em>Deterministic Selection operator</em> and pushed to the <em>next generation</em>. The <em>best of the best individuals </em>selected for the next generation with maximal fitness function value and zero penalty function value (no constraints violated) is inducted into the <em>Hall of Fame</em>.</p><p>At the end of the first generation, the next generation pool of individuals get set as the parent population and the second generation cycle begins. The second generation offspring population is now generated by repeating the reproduction process and the best of the best individuals selected for the third generation competes with the individual in the Hall of Fame. DE HOF ensures that only the best individual by way of maximal fitness function value and zero penalty function value generated this far, is inducted into the Hall of Fame.</p><p>The generation cycles progress until the termination criterion is met with, at which stage the individual in the Hall of Fame is declared to be the optimal solution to the problem concerned. For 130–30 portfolio construction a fixed number of generation cycles (600 for example) was set as the termination criterion.</p><p>Since it is integrated optimization, those positions that are to be longed or shorted to arrive at the optimal 130–30 portfolio, is known only at this stage when the algorithm terminates.</p><h4>Output</h4><p>The Hall of Fame now holds the optimal or near-optimal or acceptable solution to the problem. The genes of the HOF individual represent the optimal weights or proportion of capital to be invested in the assets of the portfolio. Positive weights indicate assets that are to be longed and negative weights indicate assets that are to be shorted.</p><p>Given the mean returns and the covariance of returns, the risk, return and Sharpe Ratio of the optimal 130–30 portfolio can be easily computed. The Sharpe Ratio is also the maximal that can be obtained within the generation cycles.</p><p>It can be verified that all the long and short positions in the optimal portfolio satisfy their respective budgets and bounds constraints and the portfolio beta equals 1, ensuring that the volatility of the optimal 130–30 portfolio matches that of the market.</p><p>(See Sec. 6.4.3 of Chapter 6 Metaheuristic 130–30 Portfolio Construction [PAI 2018] to know more about the design, process flow chart and execution of Differential Evolution with Hall of Fame based 130–30 Portfolio construction)</p><h4>7. Case Study</h4><p>The construction of 130–30 long-short portfolios is demonstrated over S&amp;P BSE200 index (April 03, 2009- July 03, 2020) data set of Bombay Stock Exchange, India, spanning across the “postpartum (2008) depression” period and ending with the “mid-Covid 19 crisis” period ( in India, of course!).</p><h4>7.1 Heuristic Portfolio Selection</h4><p>The first step entails making a prudent choice of stocks for the portfolio. A <strong><em>k-portfolio</em></strong> was picked for the 130–30 portfolio construction process. A <em>k-portfolio</em> is an outcome of a <strong>heuristic portfolio selection strategy</strong>, where the universe of stocks is grouped into clusters that display <em>intra-class similarity</em> and <em>inter-class dissimilarity</em> with regard to the <strong>mean-returns and covariance of returns</strong>. Since assets belonging to a cluster are similar in behavior or characteristics, the investor now makes a choice of picking only <em>one asset each from each cluster</em> to ensure <strong>diversification of assets in the portfolio</strong>. A clustering technique such as <strong><em>k-means</em> algorithm</strong> can be used to group the stock universe into <em>k</em> clusters with the investor exercising the choice of <em>k</em>. Thus, <em>k</em> is the portfolio size selected by the investor.</p><p>(See Chapter 3 Heuristic Portfolio Selection [PAI 2018] or the <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb">GitHub repository for Heuristic Portfolio Selection</a> and <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson4_TraditionalPortfolioConstruction/Lesson4_MainContent.ipynb">GitHub repository for Traditional Portfolio Construction</a>, to know more about the construction of <em>k</em>-portfolios and their merits when used with benchmark portfolio construction methods)</p><h4>7.2 Choice of Portfolio Size <em>k</em></h4><p>Several empirical studies have been carried out with regard to the appropriate choice of portfolio size. Chong and Phillips [ CHO 2013] concluded that “…<em>the optimal portfolio size depended greatly on the criterion being used to judge the adequacy of diversification...</em>”. Their studies showed that for risk-return ratios based measures (Sharpe Ratio for example) the optimal number of stocks could be 25, for mean returns based measures a portfolio size of 30 would suffice, for risk based measures a portfolio size of 20 and on an average, the optimal number of stock holdings could be around 31.</p><p>So in this work the <em>k</em>-portfolio was heuristically constructed for a choice of <em>k = 30</em>. However, <strong>which of these assets would be longed or shorted or which of these would be discarded (recall that the investor fixed 0 for the respective bounds of the long and short positions) would be known only after DE HOF completes its integrated optimization to arrive at the optimal 130–30 portfolio with maximal Sharpe Ratio and a portfolio beta of 1</strong>.</p><p>The <em>k</em>-portfolio comprises the following assets, after the investor made a choice of one asset each from the 30 clusters defining the S&amp;P BSE200 stock universe:</p><p>Adani Enterprises Ltd. [“ADANI ENT”], Amara Raja Batteries Ltd.[“AMARAJABAT”], Ashok Leyland Ltd.[“ASHOKLEY”], Bajaj Finance Ltd. [“BAJFINANCE”], Bharat Forge Ltd. [“BHARATFORG”], Cipla Ltd. [“CIPLA”], Coal India Ltd.[“COALINDIA”], Coromandel International Ltd. [“COROMANDEL”], Edelweiss Financial Services Ltd. [“EDELWEISS”], GAIL (India) Ltd. [“GAIL”], HDFC Bank Ltd.[“HDFCBANK”], Hindustan Petroleum Corporation Ltd. [ “HINDPETRO”], Vodafone Idea Ltd. [“IDEA”], Indian Bank Ltd. [“INDIANB”], Indian Oil Corporation Ltd.[ “IOC”], ITC Ltd. [“ITC”], JSW Steel Ltd.[ “JSWSTEEL”], Jubilant Life Sciences Ltd. [“JUBILANT”], Larsen &amp; Toubro Ltd. [“LT”], Mahindra &amp; Mahindra Ltd. [“M&amp;M”], Mindtree Ltd. [“MINDTREE”], Motilal Oswal Financial Services Ltd. [“MOTILALOFS”], NMDC Ltd. [“NMDC”], Relaxo Footwears Ltd. [“RELAXO”], State Bank of India Ltd. [“SBIN”], Shree Cement Ltd. [“‘SHREECEM’”], Tata Steel Ltd. [“‘TATASTEEL’”], Tata Consultancy Services Ltd. [“‘TCS’”], Titan Company Ltd. [“TITAN”], Wipro Ltd. [“WIPRO”]</p><p>The objective is to construct a 130–30 portfolio that will yield maximal Sharpe Ratio, subject to the constraints listed in equations [1.2]-[1.6], for a 6.5% risk free rate of return in India.</p><p>The portfolio parameters are provided as inputs through a CSV file. A fragment of the CSV file <strong>S&amp;PBSE200_k30Portfolio.csv</strong>, which describes the asset labels, mean returns, variance-covariance matrix of returns and asset betas, to be used by DE HOF for the construction of optimal 130–30 portfolio is shown in Fig. 1.1.</p><p>The DE HOF control parameters are directly provided as inputs in the main program itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*oRvw4PtmdnEgxLr9lWo1Xw.png" /><figcaption>Fig.1.1 Structure of the input file to DE HOF that captures details about assets in the portfolio, their mean and covariance of returns (daily %) and asset betas</figcaption></figure><h4>8. Software Implementation of DE HOF for 130–30 Portfolio Construction</h4><p>The DE HOF program is a conglomeration of functions typical of any metaheuristic strategy. The Python and MATLAB implementations of the strategy can be freely downloaded from the following sites:</p><h4>Python code:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/75/1*Hg4z4yoTUXxJj48WozbYPw.png" /><figcaption><a href="https://github.com/PaiViji/PythonFinance--130-30-Portfolio-Construction/blob/master/MainContent.ipynb">Python Code for 130–30 Portfolio Construction using DE HOF</a></figcaption></figure><p>Download Jupyter Notebook in Python: “MainContent.ipynb”</p><h4><strong>MATLAB code:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/86/1*PxNn-uUDJfO8weatTTw-fw.png" /><figcaption><a href="https://in.mathworks.com/matlabcentral/fileexchange/64507-metaheuristic-portfolio-optimization-models">MATLAB Code for 130–30 Portfolio Construction using DE HOF</a></figcaption></figure><p>Download from the Mathworks Central File Exchange: “Chapter6_130_30_PortfOptmzn_DEHOF_Rand4BestDir5.m”</p><p>Needless to say, users need to provide appropriate portfolio parameters and DE HOF control parameters as inputs, while re-using or replicating DE HOF for the construction of their own 130–30 portfolios.</p><h4>9. Optimal 130–30 Portfolio- Analysis of Results</h4><p>Typical of metaheuristic strategies, DE HOF strategy yields <em>multiple optimal solutions</em> during its various runs.</p><p>Fig. 1.2 and Fig. 1.3 illustrate the composition of the optimal 130–30 long short portfolios (termed Portfolio A and Portfolio B respectively, for ease of reference) obtained by DE HOF in two of its runs.</p><p>To reiterate, several of the stocks in the choice of 30 made by the investor, have been rejected by DE HOF based optimization, obviously because the bounds chosen by the investor for the long and short positions includes 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*p6TRyMopDksi85K9smgsPQ.png" /><figcaption>Fig. 1.2 Optimal 130–30 Portfolio asset allocation and characteristics — Portfolio A</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*o77msnw56GimPz2rY8VBBA.png" /><figcaption>Fig. 1.3 Optimal 130–30 Portfolio Asset Allocation and characteristics — Portfolio B</figcaption></figure><h4>9.1 Multiple solutions — Making a choice!</h4><p>Table 1.1 shows the summarized characteristics of sample optimal 130–30 portfolios delivered by DE HOF during its runs.</p><p>At this juncture it needs to be emphasized that metaheuristic strategies are inherently stochastic in nature. A random population of individuals moves over large search spaces in search of optimal solutions, through various generation cycles and in the process evolves itself into optimal or near-optimal or acceptable solutions to the problem. Thus, metaheuristic strategies are inherently endowed with the potential to generate multiple solutions to the problem in hand, during various runs. This characteristic of metaheuristic algorithms needs to be viewed meritoriously and exploited to one’s own advantage, by making a right choice of the multiple solutions delivered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*R_SYyV0ujll1BD5GZA8dCw.png" /><figcaption>Table 1.1 Optimal 130–30 Portfolios delivered by DE HOF during various runs</figcaption></figure><p>Thus, in the case of 130–30 portfolio construction, though the various runs of DE HOF yield optimal portfolios with similar characteristics of risk, return and Sharpe Ratio, the choice of long / short positions and the allocation of weights to the assets in the optimal portfolios concerned, are different and diverse for each run.</p><p>With the risk, return and Sharpe Ratio of the optimal portfolio guaranteed, it is now left to a discerning investor to make a choice of the portfolio with a composition of assets and allocation of weights that best suits his or her investment sentiments or the market ecosystem.</p><h4>9.2 Convergence Characteristics of DE HOF</h4><p>One of the reasons to study the <em>convergence</em> behavior of metaheuristic strategies is to determine the number of generations that needs to be fixed, especially when the termination criterion for the strategies involves generation count.</p><p>In the case of 130–30 portfolio construction, the convergence behavior of DE HOF was studied by observing the fitness function values of individuals inducted into the Hall of Fame (that records the best solution obtained this far) during the course of the generation cycles. Since DE HOF displays stochastic behavior, the convergence characteristics were observed over various runs. Fig. 1.4 illustrates the graph and it can be seen that the fitness function values of individuals inducted into the Hall of Fame stabilized around 100 generations and thereafter there was no significant rise in the value, signalling that the optimal or near-optimal or acceptable solution had already been attained for that specific run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*PbK9-Es77qvKzqHL7miRUg.png" /><figcaption>Fig. 1.4 Convergence behavior of DE HOF during optimal 130–30 portfolio construction</figcaption></figure><h4>10. Conclusion</h4><p>130–30 portfolios have served as good instruments to ensure investment exposure and market protection at the same time, especially during times when market behavior has been erratic — the downturns during Covid-19 crisis being a good example in recent times.</p><p>An integrated optimization of long-short portfolios can help construct optimal 130–30 portfolios with leveraged returns and maximal Sharpe Ratios and a metaheuristic strategy such as Differential Evolution with Hall of Fame can serve to construct such a portfolio.</p><p>The metaheuristic strategy is inherently endowed with the potential to deliver multiple near-optimal 130–30 portfolios, providing investors the luxury of making choices that follow their investment sentiments.</p><p>However, the hard reality of metaheuristic strategies relentlessly working over long generation cycles to evolve optimal portfolios, can be a dampener. Nevertheless, the fact that metaheuristic strategies are endowed with considerable potential to deliver acceptable solutions to complex portfolio optimization problems that traditional methods have found difficult to handle, needs to be acknowledged and accepted.</p><h4>Companion Reading</h4><p>[1] Chapter 6 Metaheuristic 130–30 Portfolio Construction [PAI 2018]</p><p>[2] Chapter 2 A Brief Primer on Metaheuristics [PAI 2018]</p><p>[3] <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb">GitHub repository for Heuristic Portfolio Selection</a></p><p>[4] <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson4_TraditionalPortfolioConstruction/Lesson4_MainContent.ipynb">GitHub repository for Traditional Portfolio Construction</a></p><h4>References</h4><p>[CHO 2003] Chong James and G Michael Phillips, “Portfolio Size: Revisited”, <em>The Journal of Wealth Management</em>, 15(4), pp. 49–60, 2013.</p><p>[FEO 2006] Feoktistov V, “<em>Differential Evolution in search of solutions</em>”, Springer, 2006.</p><p>[GRI 2000] “<em>Active Portfolio Management</em>”, 2nd Ed., Mc-Graw Hill, New York, 2000.</p><p>[JAC 1999] Jacobs B I, Levy K N and D Starer, “Long-Short Portfolio Management: An Integrated Approach”, <em>The Journal of Portfolio Management</em>, vol. 25, no. 2, pp. 23–32, 1999.</p><p>[JOH 2007] Johnson G, S Ericson and V Srimurthy, “An Empirical Analysis of 130/30 Strategies: Domestic and International 130/30 Strategies add value over Long-Only Strategies”, <em>The Journal of Alternative Investments</em>, pp. 31–42, 2007.</p><p>[JOI 1994] Joines J A and C R Houck, “On the use of Non-stationary Penalty Functions to solve Nonlinear Constrained Optimization Problems with GAs”, <em>Proceedings of the First IEEE Conference on Evolutionary Computation</em>, pp.579–584, 1994.</p><p>[LO 2007] Lo Andrew and P Patel, “130/30: The New Long Only”, <em>Journal of Portfolio Management</em>, 34(2), pp. 12–38, 2007.</p><p>[MIC 1993] Michaud R, “Are Long-Short Equity Strategies Superior?”, <em>Financial Analysts Journal</em>, vol. 49, pp. 44–50, 1993.</p><p>[PAI, 2018] Vijayalakshmi Pai G. A., “<a href="https://www.mathworks.com/academia/books/metaheuristics-for-portfolio-optimization-pai.html"><em>Metaheuristics for Portfolio Optimization- An Introduction using MATLAB</em></a>”, Wiley-ISTE, 2018.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=314a9295e1e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In search of superior Sharpe Ratio based Portfolios…]]></title>
            <link>https://medium.com/@pai.viji/in-search-of-superior-sharpe-ratio-based-portfolios-3653d1ae989?source=rss-479eaa23ba8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3653d1ae989</guid>
            <category><![CDATA[vitaoptimum]]></category>
            <category><![CDATA[diversification]]></category>
            <category><![CDATA[heuristics]]></category>
            <category><![CDATA[portfolio-optimisation]]></category>
            <category><![CDATA[sharpe-ratio]]></category>
            <dc:creator><![CDATA[Vijayalakshmi Pai]]></dc:creator>
            <pubDate>Thu, 30 Jan 2020 06:36:44 GMT</pubDate>
            <atom:updated>2020-02-02T10:14:28.659Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*FJEYAVStCpItA6VoxttL4Q.png" /><figcaption>Global Optimization of Portfolios — a rendezvous with VitaOptimum Plus!</figcaption></figure><h3>1. Prologue</h3><p><strong>Portfolio Optimization</strong> is a discipline that deals with the construction of portfolios from tradable assets such as stocks, bonds and securities, with the dual objectives of <strong><em>maximizing the expected portfolio return</em></strong> and <strong><em>minimizing portfolio risk</em></strong>. The problem models can turn complex when constraints, both linear/non-linear and representing investor preferences, market norms, investment strategies, why even religious beliefs, are incorporated into them.</p><p>Some of these optimization problem models have been satisfactorily solved, if not efficiently, using traditional methods. However, it needs to be realized that traditional methods despite their sophistication, suffer from pitfalls such as dependence on a suitable <em>starting point</em> or <em>initial point</em> in the search space from where the search for solution begins, or the need to enumerate all sets of candidate solution sets to determine the best or optimal solution which can be time consuming, or lesser quality or effectiveness of the optimal solutions to the applications concerned.</p><p>Again, there are problem models which are difficult to be solved by traditional methods. Fortunately, <strong>heuristic methods</strong> inspired by nature have helped solve these complex problems to obtain <em>acceptable or near-optimal solutions.</em></p><h3>2. Goal Post</h3><p>This research post discusses the solution of a fundamental portfolio optimization model, termed <strong>Sharpe Ratio based portfolio optimization</strong>, which mathematically, is a <em>non-linear single objective constrained optimization </em>problem.</p><p>Let us first solve the model using a traditional method viz., <strong>Sequential Least Squares Quadratic Programming (SLSQP)</strong> using a solver available in <strong>SciPy</strong>, a Python library.</p><p>Let us also solve the same problem using <strong>VitaOptimum Plus</strong>, a Python based heuristic solver, that employs cutting edge technologies of Artificial Intelligence, Evolutionary Computation, Swarm Intelligence and Advanced Statistics, to arrive at the global optimum.</p><p>So what are we up to?…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*8oofEvm9rWwuO495ssbShA.png" /><figcaption>Mirror! Mirror! on the wall…Who’s the fairest of them all?…</figcaption></figure><p>Let us explore the quality of the optimal portfolios obtained by VitaOptimum Plus -a heuristic solver, and SciPy — a traditional solver, to find answers to the questions, “Can heuristic solvers endowed with intelligence, deliver global optimal portfolios on par with traditional solvers? Can heuristic solvers reinvent themselves to deliver minimal risk or maximal return portfolios, near-optimal solutions though, to satisfy the risk appetites of investors? Can heuristic solvers ensure better diversification of assets in the portfolio? …”</p><p>Let ‘s begin…</p><h3>3. Sharpe Ratio</h3><p><strong>Sharpe Ratio</strong>, developed by Nobel Laureate William F Sharpe [SHA 66], is a measure of calculating risk adjusted return. It serves to help investors know about the returns on their investments relative to the risks they hold. The Sharpe Ratio is defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/99/1*Gex2BltjYKQUPFgjUOUhAA.gif" /></figure><p>where <em>R(x)</em> is the average rate of return on the investment <em>𝑥</em>, <em>Rf</em> is the best available <strong>risk free rate of return</strong> and <em>𝜎</em> is the standard deviation of <em>R(x)</em>, which denotes the risk on the investment.</p><p>Higher the Sharpe Ratio, more is the excess returns over that of holding a risk free investment, relative to the increased volatility that the investment is exposed to. A Sharpe Ratio of 0, needless to say, only denotes the investment to be risk-free or one that does not yield any excess return. In practice, while a Sharpe ratio of 1 marks the investment to be acceptable or good for investors, a value less than 1 grades the investment as sub-optimal, and values greater than 1 and moving towards 2 or 3, grade the investments as highly superior.</p><h3>4. Maximizing Sharpe Ratio</h3><p>Having understood the significance of the Sharpe Ratio, let us suppose an investor wishes to make an investment in assets in such a way that the Sharpe Ratio of the portfolio would be the best possible or the maximum that can be ensured for that investment.</p><p>Let P be a portfolio comprising assets 𝐴1,𝐴2,…𝐴𝑁 with weights 𝑊1,𝑊2,…𝑊𝑁 and <em>𝜇</em>1,<em>𝜇</em>2,…<em>𝜇</em>𝑁 as the asset returns. (See <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson1_FundaRiskReturnPortfolio/Lesson1_MainContent.ipynb"><strong>Lesson 1 Fundamentals of Risk and Return of a Portfolio</strong></a> to know about risk and return of a portfolio).</p><p>To keep the discussion simple for now, let us suppose that the investor decides to enforce only <strong>basic constraints</strong> on the portfolio. (See Sec. 5.2 of <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson5_MeanVarianceOptimization/Lesson5_MainContent.ipynb"><strong>Lesson 5 Mean Variance Optimization Model</strong></a> to know about basic constraints).</p><p>The mathematical model for the Sharpe Ratio based Portfolio Optimization is given by,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*EK_37rozejZXmT7pEQTZTA.png" /></figure><p>The numerator of the objective function denotes the excess returns of the investment over that of a risk free asset <em>𝑅𝑓</em> and the denominator the risk of the investment. The objective is to maximize the Sharpe Ratio. The basic constraints indicate that the investor wishes to have a <strong>fully invested</strong> portfolio, in other words, invest 100% of the capital in the portfolio.</p><h3>5. Solving the Sharpe Ratio Optimization Model using SciPy</h3><p>To solve the Sharpe Ratio maximization model, let us make use of the <strong>minimize</strong> library function from <strong>scipy.optimize</strong> package of Python, adopting the <em>Sequential Least Squares Quadratic Programming</em> (SLSQP)method.</p><p>The Python code for the function <strong>MaximizeSharpeRatioOptimization</strong>, which defines the objective function and the basic constraints represented by the aforementioned equation, is shown here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/170a2117426a047c3befb6348b8d80bf/href">https://medium.com/media/170a2117426a047c3befb6348b8d80bf/href</a></iframe><h3><strong>6. Solving the Sharpe Ratio Optimization Model using <em>VitaOptimum Plus</em></strong></h3><p>VitaOptimum Plus [VIT, 2019] is a state-of-the-art global optimization solver encompassing the cutting edge technologies of Artificial Intelligence, Evolutionary Computation, Swarm Intelligence and Advanced Statistics, to efficiently tackle constrained linear and non-linear models. <br>The Sharpe ratio based portfolio optimization model described in the aforementioned equation and employing the <strong>Ccs</strong> (<strong>C</strong>ontinuous <strong>c</strong>onstrained <strong>s</strong>olver) Python class from <strong>vitaoptimum.voplus.ccs</strong> package is shown below.</p><p>Unlike traditional methods, which yield unique optimal solutions to the problem models concerned as decided by the initial points chosen by the solvers, VitaOptimum Plus following heuristics, exhibits the potential to obtain both global optimal or multiple near-optimal solutions by enabling the user to calibrate the quality measures ( <strong>qmeasures</strong>) array, during different runs.</p><p>Thus if quality measures array was set to qmeasures = np.array([1.0e-16, 1.0e-15, 1.0e-15, 0.0], dtype = ctypes.c_double). It can be seen that the behavior of VitaOptimum Plus solver is similar to that of the SciPy solver. However, the behavior of the VitaOptimum Plus solver can be controlled by configuring the <strong>qmeasures</strong> array appropriately, to deliver near-optimal or acceptable solutions as desired by the user. The behavior of the solver can also be observed by studying <strong>qmeasures</strong> values before and after optimization. More details on this can be found in the VitaOptimum Plus manual.</p><p>In general, this predominant characteristic of heuristic algorithms, which exhibit the potential to deliver both global optima or multiple near-optimum or acceptable solutions, by allowing the users to calibrate their respective control parameters to enhance or alter their behavior, is a boon that can be taken advantage of, while deciding on an effective or practical solution to the problem concerned, from the multifarious choices available.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30e6b90977b6cd168162467d6d6cd5f8/href">https://medium.com/media/30e6b90977b6cd168162467d6d6cd5f8/href</a></iframe><h3>7. Case Study</h3><p>Let us suppose that an investor decides to invest in a portfolio comprising the following Dow stocks. While a typical portfolio is a prudent combination of assets comprising equities, bonds, currencies etc., as dictated by the investor’s risk appetite, let us restrict our study to an equity based portfolio, just to keep the narrative simple. <br> <br>The following are the Dow stocks that has interested the investor:</p><p>{Coca-Cola (KO), United Health (UNH), Walt Disney (DIS), IBM (IBM), Cisco (CSCO), JPMorgan Chase (JPM), Goldman Sachs (GS), Walgreens Boots Alliance (WBA), Apple (AAPL), Home Depot (HD), American Express (AXP), McDonald’s (MCD), Merck (MRK), Boeing (BA), Caterpillar (CAT)}</p><p>The investor desires to obtain the optimal portfolio set that would yield the maximal Sharpe Ratio. The objective therefore, is to find the optimal weights that will ensure maximal Sharpe Ratio for the portfolio. In other words, the investor wishes to know what proportion of capital must be invested in each of the stocks so that the portfolio yields maximal Sharpe ratio.</p><p>The historical data set Dow 30 (April 11 2014 -April 11 2019) is used to obtain the mean returns and variance-covariance matrix of returns, of the assets comprising the portfolio.</p><h3>8. SciPy solver Vs VitaOptimum Plus solver</h3><p>Here are the experiments and the observations with regard to the quality of the optimal portfolios obtained by the <strong>minimize</strong> solver of SciPy and <strong>Ccs</strong> solver of VitaOptimum Plus!</p><h4>8.1 Diversification Ratios of the optimal portfolios</h4><p>Diversification involves investments in different assets or asset classes or markets. A portfolio that comprises such a diversified set of securities can go a long way in mitigating risk since the securities would react differently to market events.</p><p>A <strong>Diversification Index</strong> quantifies diversification. There are several diversification indices discussed in the literature. <strong>Diversification Ratio </strong>proposed and patented by Yves Choueifaty in 2008 [CHO 08, CHO 13], is a diversification index of recent origin, built on the inter-dependence between assets of a portfolio. Diversification Ratio is the <strong><em>ratio of the weighted sum of individual asset volatilities to the portfolio’s volatility</em></strong>.</p><p><strong>A portfolio that is <em>most diversified</em> would yield the <em>maximal Diversification Ratio</em>.</strong></p><p>Table 1 illustrates the maximal Sharpe Ratio, Annualized Risk(%), Expected Portfolio Return (%) and Diversification Ratio of the optimal portfolio obtained by SciPy and VitaOptimum Plus solvers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*GYUNAOHyCJoJyosc7kffrw.png" /></figure><p>While SciPy solver delivers a unique optimal solution, VitaOptimum Plus delivers multiple solutions during different runs. For this demonstration, VitaOptimum Plus was experimented with the quality measures set to its default value, viz., qmeasures = np.zeros (4, dtype = ctypes.c_double) to obtain near optimal solutions that should be of interest to specific investor preferences.</p><p>A choice of optimal portfolios delivered by VitaOptimum Plus solver during multiple runs and selected by different investors based on their risk appetites, in the background of maximal Sharpe Ratios of the portfolios, have been shown in the table. It can be seen that some investors have opted for minimal risk or maximal diversification ratio portfolios, while others have opted for maximal return portfolios. The fact that VitaOptimum Plus accommodates such choices due to its potential to deliver multiple near-optimal solutions, contributes to its broad based practical appeal and successful application.</p><p>To recall once again, users can configure the behavior of the solver by appropriately setting the values of the array variable <strong>qmeasures</strong>, which describes the four analytical measures of convergence of the <strong>Ccs</strong> solver, in function <strong>GlobalMaxSharpeRatioOptmzn</strong>.</p><h4>8.2 Percentage Contributions to Portfolio Risk</h4><p>Fig. 1 illustrates the Percentage contributions to total risk computed for the optimal portfolio obtained by the SciPy solver. Fig. 2 illustrates the same for a near-optimal portfolio with minimal risk selected by an investor, using VitaOptimum Plus solver. The characteristics of the optimal/near-optimal portfolios have been listed below the figures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*kFk29EBsSqttC5xu88bgbg.png" /><figcaption>Fig. 1 SciPy minimize solver portfolio: Percentage contributions to portfolio risk</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*vRPku7a7SHUQNLo2l-p_7Q.png" /><figcaption>Fig. 2 VitaOptimum Plus Ccs solver portfolio : Percentage Contributions to portfolio risk <a href="http://localhost:8888/notebooks/Documents/GAVPai/GitHubLesson6/VOPlus_MaxSharpeRatioOptmzn.ipynb#Fig.-2--VitaOptimum-Plus-Ccs--solver-portfolio-:-Percentage-Contributions-to-portfolio--risk--">¶</a></figcaption></figure><h4>8.3 Optimal Asset Allocation</h4><p>The optimal asset allocation represented by the optimal weights and arrived at by SciPy’s minimize solver has been shown in Fig. 3. Fig. 4 illustrates the same for a near-optimal minimal risk portfolio opted for by the investor and delivered by VitaOptimum Plus’s Ccs solver. The characteristics of the optimal/near-optimal portfolios have been listed below the figures.</p><p>It can be seen that for a Maximal Sharpe Ratio of 1.28 and Diversification Ratio of 1.39, the SciPy solver yields an optimal portfolio where nine of the 15 stocks selected by the investor have been excluded from investing (zero weights), which may not be acceptable to the investor. The practicality of the optimal solution given the investor’s preference, leaves much to be desired.</p><p>On the other hand, VitaOptimum Plus’s Ccs solver is able to deliver a minimal risk portfolio, near-optimal though, but with a larger Diversification Ratio of 1.41, as preferred by the investor. It can be seen that the allocation of weights are distributed across assets lending to the practicality of the investment. As mentioned earlier, configuring array variable <strong>qmeasures</strong> can help control or enhance the behavior of the VitaOptimum Plus solver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*MF_H1RPo4z8lWuLnflJvjA.png" /><figcaption>Fig 3. Optimal Asset Allocation by SciPy’s minimize solver</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*LMFSpS67IApEpwPQZTQiDg.png" /><figcaption>Fig.4 Near-optimal Asset Allocation by VitaOptimum Plus’s Ccs solver for a minimum risk portfolio</figcaption></figure><h3>9. Conclusion</h3><p>SciPy solver indeed yields a unique and distinct optimal portfolio that reports maximal Sharpe Ratio. However, VitaOptimum Plus driven by heuristics, not just exhibits the potential to deliver a global optimum solution but also multiple near-optimal or acceptable solutions that can cater to the risk appetites or preferences of the investors, resulting in portfolios that are less risky or better diversified or well distributed.</p><p>The fact that the behavior of the VitaOptimum Plus solver can be controlled or enhanced by configuring the solver’s control parameters is an added advantage that could be made use of by a discerning user.</p><h3>Companion Reading</h3><p><strong>Jupyter Notebook in Python</strong> for the results and discussion in this post can be accessed from the GitHub repository <a href="https://github.com/PaiViji/PythonFinance--Global-optimization-of-portfolios-a-rendezvous-with-VitaOptimum-Plus/blob/master/MaxSharpeRatioOptmzn_MainContent.ipynb"><em>PythonFinance--Global-optimization-of-portfolios-a-rendezvous-with-VitaOptimum-Plus</em></a></p><p><a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson1_FundaRiskReturnPortfolio/Lesson1_MainContent.ipynb">Lesson 1 Fundamentals of Risk and Return of a portfolio</a><br><a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb">Lesson 3 Heuristic Portfolio Selection</a><br><a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson5_MeanVarianceOptimization/Lesson5_MainContent.ipynb">Lesson 5 Mean Variance Optimization Model</a></p><h3>References</h3><p>[CHO 08] Choueifaty Yves and Y Coignard, Toward Maximum Diversification, <em>The Journal of Portfolio Management</em>, pp. 40–51, 2008.</p><p>[CHO 13] Choueifaty Yves, T Froidure and J Reynier, Properties of the Most Diversified Portfolio, <em>Journal of Investment Strategies</em>, 2(2), pp. 49–70, 2013.</p><p>[SHA 66] Sharpe, William F. Mutual Fund Performance, <em>Journal of Business</em>, January 1966, pp. 119–138.</p><p>[PAI 18] Vijayalakshmi Pai G. A., <a href="https://www.mathworks.com/academia/books/metaheuristics-for-portfolio-optimization-pai.html">Metaheuristics for Portfolio Optimization- An Introduction using MATLAB</a>, Wiley-ISTE, 2018.</p><p>[VIT, 2019]<a href="http://skyworkflows.com/wp-content/uploads/2019/07/VitaOptimum-by-SkyWorkflows-small.pdf"> http://skyworkflows.com/wp-content/uploads/2019/07/VitaOptimum-by-SkyWorkflows-small.pdf</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3653d1ae989" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python for Portfolio Optimization-The Ascent!]]></title>
            <link>https://medium.com/@pai.viji/python-for-portfolio-optimization-the-ascent-20eb6e520765?source=rss-479eaa23ba8b------2</link>
            <guid isPermaLink="false">https://medium.com/p/20eb6e520765</guid>
            <category><![CDATA[python-for-finance]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[k-means-clustering]]></category>
            <category><![CDATA[asset-allocation]]></category>
            <category><![CDATA[portfolio-optimisation]]></category>
            <dc:creator><![CDATA[Vijayalakshmi Pai]]></dc:creator>
            <pubDate>Sat, 07 Sep 2019 06:44:29 GMT</pubDate>
            <atom:updated>2019-09-07T06:44:29.844Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*KlDsSDiYHH3hzqogKOPdHQ.png" /><figcaption>“I can do it!”- the Ascent!</figcaption></figure><p>First lessons to ascend the hilly terrain of Portfolio Optimization in seven strides (Lessons), beginning with the fundamentals (Lesson 1) and climbing slope after slope (Lessons 2–6), to reach the first peak of constrained portfolio optimization models (Lesson 7), amongst a range of peaks waiting beyond!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/139/1*TKFFDYJrSlmGSH7V84IQmA.png" /></figure><p>Lesson 1: <strong>Fundamentals of Risk and Return of a Portfolio</strong></p><p><strong>Goal:</strong> How does one invest in a portfolio of stocks and know about the returns and risks involved?</p><p><strong>Jupyter Notebook : </strong><a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson1_FundaRiskReturnPortfolio/Lesson1_MainContent.ipynb"><em>Lesson1_MainContent.ipynb</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/130/1*HJlDeKh1aQ_LzWbMHXep6w.png" /></figure><p>Lesson 2<strong>: Some glimpses of Financial Data Wrangling</strong></p><p><strong>Goal</strong>: Why is it essential to clean and transform raw financial data, before they are used to make investment decisions?</p><p><strong>Jupyter Notebook: </strong><a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson2_FinDataWrangling/Lesson2_MainContent.ipynb"><em>Lesson2_MainContent.ipynb</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/134/1*oaYJGxV-MlHZ9t2wjWbfyg.png" /></figure><p>Lesson 3: <strong>Heuristic Portfolio Selection</strong></p><p><strong>Goal</strong>: Given the vast and variegated universe of securities, how can one make a prudent and efficient choice of securities for one’s portfolio?</p><p><strong>Jupyter Notebook: </strong><a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson3_HeuristicPortfolioSelection/Lesson3_MainContent.ipynb"><em>Lesson3_MainContent.ipynb</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/111/1*5iyzUuCGKBgamIJcAwk8vg.png" /></figure><p>Lesson 4: <strong>Traditional Methods for Portfolio Construction</strong></p><p><strong>Goal</strong>: How would an investor know how much to invest in each one of the assets in the portfolio?</p><p><strong>Jupyter Notebook</strong>: <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson4_TraditionalPortfolioConstruction/Lesson4_MainContent.ipynb"><em>Lesson4_MainContent.ipynb</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/117/1*6JoN8WBbO2WOES496sGULg.png" /></figure><p>Lesson 5: <strong>Mean-Variance Optimization of Portfolios</strong></p><p><strong>Goal</strong>: How would one determine the optimal weights which will ensure maximum return and minimum risk for the portfolio that one is invested in?</p><p><strong>Jupyter Notebook: </strong><a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson5_MeanVarianceOptimization/Lesson5_MainContent.ipynb"><em>Lesson5_MainContent.ipynb</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/118/1*-4qUmyWVqAntZzSboBSpZA.png" /></figure><p>Lesson 6:<strong> Sharpe Ratio based Portfolio Optimization</strong></p><p><strong>Goal</strong>: If a portfolio with higher Sharpe Ratio than its counterparts, is considered superior to them, then how does one invest in the assets of the portfolio, to ensure maximal Sharpe Ratio?</p><p><strong>Jupyter Notebook: </strong><a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson6_SharpeRatioOptimization/Lesson6_MainContent.ipynb"><em>Lesson6_MainContent.ipynb</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/114/1*L27zu3pe5K9Oym76W6Tr_g.png" /></figure><p>Lesson 7:<strong> Constrained Portfolio Optimization</strong></p><p><strong>Goal:</strong> How can an investor know how much to invest in a portfolio of the investor’s choice, which besides the objectives of maximizing return and minimizing risk, is constrained by the investor’s preference for certain asset classes or assets, or imposition of capital budgets over selective assets in the portfolio?</p><p><strong>Jupyter Notebook</strong>: <a href="https://github.com/PaiViji/PythonFinance-PortfolioOptimization/blob/master/Lesson7_ConstrainedPortfolioOptimization/Lesson7_MainContent.ipynb"><em>Lesson7_MainContent.ipynb</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*_BmuaNpO6A2gyHAx4q3EhA.png" /><figcaption>“I made it!” — the ultimate triumph!</figcaption></figure><p><strong>Bibliography</strong></p><p><strong>GitHub Repository</strong> : <a href="https://github.com/PaiViji"><strong>PythonFinance-Portfolio Optimization</strong></a> . <em>The data sets and the Jupyter Notebooks can be accessed from this repository.</em></p><p>Vijayalakshmi Pai G. A., <a href="https://www.mathworks.com/academia/books/metaheuristics-for-portfolio-optimization-pai.html"><strong>Metaheuristics for Portfolio Optimization- <em>An Introduction using MATLAB</em></strong></a>, Wiley-ISTE, 2018.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20eb6e520765" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>