FixFloatClient.java

  1. package org.drip.sample.service;

  2. import org.drip.analytics.date.*;
  3. import org.drip.json.parser.Converter;
  4. import org.drip.json.simple.JSONObject;
  5. import org.drip.service.env.EnvManager;
  6. import org.drip.service.json.KeyHoleSkeleton;

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

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

  53. /**
  54.  * FixFloatClient demonstrates the Invocation and Examination of the JSON-based Fix Float Valuation Service
  55.  *  Client.
  56.  *
  57.  * @author Lakshmi Krishnamurthy
  58.  */

  59. public class FixFloatClient {

  60.     @SuppressWarnings ("unchecked") public static final void main (
  61.         final String[] astrArgs)
  62.         throws Exception
  63.     {
  64.         EnvManager.InitEnv ("");

  65.         JulianDate dtSpot = DateUtil.Today();

  66.         String strCurrency = "USD";

  67.         String[] astrDepositMaturityTenor = new String[] {
  68.             "01D",
  69.             "04D",
  70.             "07D",
  71.             "14D",
  72.             "30D",
  73.             "60D"
  74.         };

  75.         double[] adblDepositQuote = new double[] {
  76.             0.0013,     //  1D
  77.             0.0017,     //  2D
  78.             0.0017,     //  7D
  79.             0.0018,     // 14D
  80.             0.0020,     // 30D
  81.             0.0023      // 60D
  82.         };

  83.         double[] adblFuturesQuote = new double[] {
  84.             0.0027,
  85.             0.0032,
  86.             0.0041,
  87.             0.0054,
  88.             0.0077,
  89.             0.0104,
  90.             0.0134,
  91.             0.0160
  92.         };

  93.         String[] astrFixFloatMaturityTenor = new String[] {
  94.             "04Y",
  95.             "05Y",
  96.             "06Y",
  97.             "07Y",
  98.             "08Y",
  99.             "09Y",
  100.             "10Y",
  101.             "11Y",
  102.             "12Y",
  103.             "15Y",
  104.             "20Y",
  105.             "25Y",
  106.             "30Y",
  107.             "40Y",
  108.             "50Y"
  109.         };

  110.         double[] adblFixFloatQuote = new double[] {
  111.             0.0166,     //   4Y
  112.             0.0206,     //   5Y
  113.             0.0241,     //   6Y
  114.             0.0269,     //   7Y
  115.             0.0292,     //   8Y
  116.             0.0311,     //   9Y
  117.             0.0326,     //  10Y
  118.             0.0340,     //  11Y
  119.             0.0351,     //  12Y
  120.             0.0375,     //  15Y
  121.             0.0393,     //  20Y
  122.             0.0402,     //  25Y
  123.             0.0407,     //  30Y
  124.             0.0409,     //  40Y
  125.             0.0409      //  50Y
  126.         };

  127.         JSONObject jsonParameters = new JSONObject();

  128.         jsonParameters.put ("SpotDate", dtSpot.toString());

  129.         jsonParameters.put ("Currency", strCurrency);

  130.         jsonParameters.put ("FixFloatMaturity", "05Y");

  131.         jsonParameters.put ("FixFloatCoupon", 0.0206);

  132.         jsonParameters.put ("DepositTenor", Converter.Array (astrDepositMaturityTenor));

  133.         jsonParameters.put ("DepositQuote", Converter.Array (adblDepositQuote));

  134.         jsonParameters.put ("FuturesQuote", Converter.Array (adblFuturesQuote));

  135.         jsonParameters.put ("FixFloatTenor", Converter.Array (astrFixFloatMaturityTenor));

  136.         jsonParameters.put ("FixFloatQuote", Converter.Array (adblFixFloatQuote));

  137.         JSONObject jsonRequest = new JSONObject();

  138.         jsonRequest.put ("API", "FIXFLOAT::SECULARMETRICS");

  139.         jsonRequest.put ("Parameters", jsonParameters);

  140.         System.out.println ("\n\t|---------------- JSON REQUEST -----------------|\n");

  141.         System.out.println (jsonRequest.toJSONString());

  142.         System.out.println ("\n\t|---------------- JSON RESPONSE ----------------|\n");

  143.         System.out.println (KeyHoleSkeleton.Thunker (jsonRequest.toJSONString()));
  144.     }
  145. }