CustomSwapMeasures.java

  1. package org.drip.sample.oisapi;

  2. import java.util.*;

  3. import org.drip.analytics.date.*;
  4. import org.drip.service.product.OvernightIndexSwapAPI;

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

  8. /*!
  9.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  11.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  12.  *
  13.  *  This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model
  14.  *      libraries targeting analysts and developers
  15.  *      https://lakshmidrip.github.io/DRIP/
  16.  *  
  17.  *  DRIP is composed of four main libraries:
  18.  *  
  19.  *  - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/
  20.  *  - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/
  21.  *  - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/
  22.  *  - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/
  23.  *
  24.  *  - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options,
  25.  *      Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA
  26.  *      Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV
  27.  *      Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM
  28.  *      Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics.
  29.  *
  30.  *  - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy
  31.  *      Incorporator, Holdings Constraint, and Transaction Costs.
  32.  *
  33.  *  - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality.
  34.  *
  35.  *  - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning.
  36.  *
  37.  *  Licensed under the Apache License, Version 2.0 (the "License");
  38.  *      you may not use this file except in compliance with the License.
  39.  *  
  40.  *  You may obtain a copy of the License at
  41.  *      http://www.apache.org/licenses/LICENSE-2.0
  42.  *  
  43.  *  Unless required by applicable law or agreed to in writing, software
  44.  *      distributed under the License is distributed on an "AS IS" BASIS,
  45.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  46.  *  
  47.  *  See the License for the specific language governing permissions and
  48.  *      limitations under the License.
  49.  */

  50. /**
  51.  * CustomSwapMeasures demonstrates the Invocation and Usage of the OIS API.
  52.  *
  53.  * @author Lakshmi Krishnamurthy
  54.  */

  55. public class CustomSwapMeasures {

  56.     public static void main (
  57.         final String[] astrArgs)
  58.         throws Exception
  59.     {
  60.         JulianDate dtSpot = DateUtil.Today();

  61.         String strOISCurrency = "USD";
  62.         String strOISTenor = "3W";
  63.         double dblOISCoupon = 0.0043;

  64.         String[] astrOvernightCurveDepositTenor = new String[] {
  65.             "1D"
  66.         };

  67.         double[] adblOvernightCurveDepositQuote = new double[] {
  68.             0.0010
  69.         };

  70.         String[] astrOvernightCurveOISTenor = new String[] {
  71.             "1W",
  72.             "2W",
  73.             "3W",
  74.             "1M",
  75.             "2M",
  76.             "3M",
  77.             "4M",
  78.             "5M",
  79.             "6M",
  80.             "9M",
  81.             "1Y",
  82.             "18M",
  83.             "2Y",
  84.             "3Y",
  85.             "4Y",
  86.             "5Y"
  87.         };

  88.         double[] adblOvernightCurveOISQuote = new double[] {
  89.             0.0020, // 1W
  90.             0.0028, // 2W
  91.             0.0043, // 3W
  92.             0.0064, // 1M
  93.             0.0086, // 2M
  94.             0.0109, // 3M
  95.             0.0133, // 4M
  96.             0.0154, // 5M
  97.             0.0171, // 6M
  98.             0.0210, // 9M
  99.             0.0231, // 1Y
  100.             0.0234, // 18M
  101.             0.0235, // 2Y
  102.             0.0235, // 3Y
  103.             0.0237, // 4Y
  104.             0.0240  // 5Y
  105.         };

  106.         Map<String, Double> mapMeasures = OvernightIndexSwapAPI.ValuationMetrics (
  107.             strOISCurrency,
  108.             strOISTenor,
  109.             dblOISCoupon,
  110.             dtSpot.julian(),
  111.             astrOvernightCurveDepositTenor,
  112.             adblOvernightCurveDepositQuote,
  113.             astrOvernightCurveOISTenor,
  114.             adblOvernightCurveOISQuote,
  115.             false
  116.         );

  117.         Set<String> setstrKeys = mapMeasures.keySet();

  118.         for (String strKey : setstrKeys)
  119.             System.out.println ("\t" + strKey + " => " + mapMeasures.get (strKey));
  120.     }
  121. }