OToole2013.java

  1. package org.drip.sample.blacklitterman;

  2. import org.drip.numerical.common.FormatUtil;
  3. import org.drip.numerical.linearalgebra.Matrix;
  4. import org.drip.service.env.EnvManager;

  5. /*
  6.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  7.  */

  8. /*!
  9.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  11.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  12.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  13.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  14.  *
  15.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  16.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  17.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  18.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  19.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  20.  *      and computational support.
  21.  *  
  22.  *      https://lakshmidrip.github.io/DROP/
  23.  *  
  24.  *  DROP is composed of three modules:
  25.  *  
  26.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  27.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  28.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  29.  *
  30.  *  DROP Product Core implements libraries for the following:
  31.  *  - Fixed Income Analytics
  32.  *  - Loan Analytics
  33.  *  - Transaction Cost Analytics
  34.  *
  35.  *  DROP Portfolio Core implements libraries for the following:
  36.  *  - Asset Allocation Analytics
  37.  *  - Asset Liability Management Analytics
  38.  *  - Capital Estimation Analytics
  39.  *  - Exposure Analytics
  40.  *  - Margin Analytics
  41.  *  - XVA Analytics
  42.  *
  43.  *  DROP Computational Core implements libraries for the following:
  44.  *  - Algorithm Support
  45.  *  - Computation Support
  46.  *  - Function Analysis
  47.  *  - Model Validation
  48.  *  - Numerical Analysis
  49.  *  - Numerical Optimizer
  50.  *  - Spline Builder
  51.  *  - Statistical Learning
  52.  *
  53.  *  Documentation for DROP is Spread Over:
  54.  *
  55.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  56.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  57.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  58.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  59.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  60.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  61.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  62.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  63.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  64.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  65.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  66.  *
  67.  *  Licensed under the Apache License, Version 2.0 (the "License");
  68.  *      you may not use this file except in compliance with the License.
  69.  *  
  70.  *  You may obtain a copy of the License at
  71.  *      http://www.apache.org/licenses/LICENSE-2.0
  72.  *  
  73.  *  Unless required by applicable law or agreed to in writing, software
  74.  *      distributed under the License is distributed on an "AS IS" BASIS,
  75.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  76.  *  
  77.  *  See the License for the specific language governing permissions and
  78.  *      limitations under the License.
  79.  */

  80. /**
  81.  * <i>OToole2013</i> reconciles the Outputs of the Black-Litterman Model Process. The References are:
  82.  *  
  83.  * <br><br>
  84.  *  <ul>
  85.  *      <li>
  86.  *          He. G., and R. Litterman (1999): <i>The Intuition behind the Black-Litterman Model Portfolios</i>
  87.  *              <b>Goldman Sachs Asset Management</b>
  88.  *      </li>
  89.  *      <li>
  90.  *          O'Toole, R. (2013): The Black-Litterman Model: The Risk Budgeting Perspective <i>Journal of Asset
  91.  *              Management</i> <b>14 (1)</b> 2-13
  92.  *      </li>
  93.  *  </ul>
  94.  *  
  95.  * <br><br>
  96.  *  <ul>
  97.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  98.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/TransactionCostAnalyticsLibrary.md">Transaction Cost Analytics</a></li>
  99.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">DROP API Construction and Usage</a></li>
  100.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/blacklitterman/README.md">Canonical Black Litterman and Extensions</a></li>
  101.  *  </ul>
  102.  * <br><br>
  103.  *
  104.  * @author Lakshmi Krishnamurthy
  105.  */

  106. public class OToole2013 {

  107.     public static final void main (
  108.         final String[] astArgs)
  109.         throws Exception
  110.     {
  111.         EnvManager.InitEnv (
  112.             "",
  113.             true
  114.         );

  115.         String[] astrG7 = new String[] {
  116.             "Australia                ",
  117.             "Canada                   ",
  118.             "France                   ",
  119.             "Germany                  ",
  120.             "Japan                    ",
  121.             "United Kingdom           ",
  122.             "United States of America "
  123.         };

  124.         double[][] aadblG7ExcessReturnsCorrelation = new double[][] {
  125.             {1.000, 0.488, 0.478, 0.515, 0.439, 0.512, 0.491},
  126.             {0.488, 1.000, 0.664, 0.655, 0.310, 0.608, 0.779},
  127.             {0.478, 0.664, 1.000, 0.861, 0.355, 0.783, 0.668},
  128.             {0.515, 0.655, 0.861, 1.000, 0.354, 0.777, 0.653},
  129.             {0.439, 0.310, 0.355, 0.354, 1.000, 0.405, 0.306},
  130.             {0.512, 0.608, 0.783, 0.777, 0.405, 1.000, 0.652},
  131.             {0.491, 0.779, 0.668, 0.653, 0.306, 0.652, 1.000}
  132.         };

  133.         double[] adblG7ExcessReturnsVolatility = new double[] {
  134.             0.160,
  135.             0.203,
  136.             0.248,
  137.             0.271,
  138.             0.210,
  139.             0.200,
  140.             0.187
  141.         };

  142.         double[] adblG7BenchmarkWeight = new double[] {
  143.             0.016,
  144.             0.022,
  145.             0.052,
  146.             0.055,
  147.             0.116,
  148.             0.124,
  149.             0.615
  150.         };

  151.         double[] adblG7ImpliedReturnsReconciler = new double[] {
  152.             0.0394,
  153.             0.0692,
  154.             0.0836,
  155.             0.0903,
  156.             0.0430,
  157.             0.0677,
  158.             0.0756
  159.         };

  160.         double dblDelta = 2.5;
  161.         double[][] aadblG7Covariance = new double[astrG7.length][astrG7.length];

  162.         for (int i = 0; i < astrG7.length; ++i) {
  163.             for (int j = 0; j < astrG7.length; ++j)
  164.                 aadblG7Covariance[i][j] = aadblG7ExcessReturnsCorrelation[i][j] * adblG7ExcessReturnsVolatility[i] * adblG7ExcessReturnsVolatility[j];
  165.         }

  166.         double[] adblG7ImpliedReturns = Matrix.Product (
  167.             aadblG7Covariance,
  168.             adblG7BenchmarkWeight
  169.         );

  170.         System.out.println ("\n\t|-----------------------------------------------------------------------------------||");

  171.         System.out.println ("\t|                         G7 CORRELATION MATRIX INPUT                               ||");

  172.         System.out.println ("\t|-----------------------------------------------------------------------------------||");

  173.         for (int i = 0; i < astrG7.length; ++i) {
  174.             String strDump = "\t| " + astrG7[i] + " ";

  175.             for (int j = 0; j < astrG7.length; ++j)
  176.                 strDump += "|" + FormatUtil.FormatDouble (aadblG7ExcessReturnsCorrelation[i][j], 1, 3, 1.) + " ";

  177.             System.out.println (strDump + "||");
  178.         }

  179.         System.out.println ("\t|-----------------------------------------------------------------------------------||\n");

  180.         System.out.println ("\t|-----------------------------------------------------------------------------------||");

  181.         System.out.println ("\t|                         G7 COVARIANCE MATRIX INPUT                                ||");

  182.         System.out.println ("\t|-----------------------------------------------------------------------------------||");

  183.         for (int i = 0; i < astrG7.length; ++i) {
  184.             String strDump = "\t| " + astrG7[i] + " ";

  185.             for (int j = 0; j < astrG7.length; ++j)
  186.                 strDump += "|" + FormatUtil.FormatDouble (aadblG7Covariance[i][j], 1, 3, 1.) + " ";

  187.             System.out.println (strDump + "||");
  188.         }

  189.         System.out.println ("\t|-----------------------------------------------------------------------------------||\n");

  190.         System.out.println ("\t||----------------------------------------------||");

  191.         System.out.println ("\t||     BENCHMARK WEIGHT AND RETURNS VOLATILITY  ||");

  192.         System.out.println ("\t||----------------------------------------------||");

  193.         System.out.println ("\t||        ASSET CLASS        => WEIGHT |   VOL  ||");

  194.         System.out.println ("\t||----------------------------------------------||");

  195.         for (int i = 0; i < astrG7.length; ++i)
  196.             System.out.println (
  197.                 "\t|| " + astrG7[i] + " => " +
  198.                 FormatUtil.FormatDouble (adblG7BenchmarkWeight[i], 2, 1, 100.) + "% | " +
  199.                 FormatUtil.FormatDouble (adblG7ExcessReturnsVolatility[i], 2, 1, 100.) + "% ||"
  200.             );

  201.         System.out.println ("\t||----------------------------------------------||\n");

  202.         System.out.println ("\t||----------------------------------------------||");

  203.         System.out.println ("\t||          RISK PREMIUM IMPLIED RETURNS        ||");

  204.         System.out.println ("\t||----------------------------------------------||");

  205.         System.out.println ("\t||         ASSET CLASS       => OUTPUT |  PAPER ||");

  206.         System.out.println ("\t||----------------------------------------------||");

  207.         for (int i = 0; i < adblG7ImpliedReturns.length; ++i)
  208.             System.out.println (
  209.                 "\t|| " + astrG7[i] + " => " +
  210.                 FormatUtil.FormatDouble (dblDelta * adblG7ImpliedReturns[i], 1, 2, 100.) + "% | " +
  211.                 FormatUtil.FormatDouble (adblG7ImpliedReturnsReconciler[i], 1, 2, 100.) + "% ||"
  212.             );

  213.         System.out.println ("\t||----------------------------------------------||\n");

  214.         EnvManager.TerminateEnv();
  215.     }
  216. }