PrepayAssetBackedClient.java

  1. package org.drip.sample.service;

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

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

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

  51. /**
  52.  * PrepayAssetBackedClient demonstrates the Invocation and Examination of the JSON-based Pre-payable
  53.  *  Constant Payment Asset Backed Loan Service Client.
  54.  *
  55.  * @author Lakshmi Krishnamurthy
  56.  */

  57. public class PrepayAssetBackedClient {

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

  63.         double dblBeginPrincipalFactor = 1.;
  64.         double dblCouponRate = 0.1189;
  65.         double dblServiceFeeRate = 0.00;
  66.         double dblCPR = 0.01;
  67.         double dblBondNotional = 147544.28;
  68.         String strDayCount = "Act/365";
  69.         String strCurrency = "USD";
  70.         int iNumPayment = 48;
  71.         int iPayFrequency = 12;
  72.         double dblFixedMonthlyAmount = 3941.98;

  73.         JulianDate dtEffective = DateUtil.CreateFromYMD (
  74.             2015,
  75.             DateUtil.OCTOBER,
  76.             22
  77.         );

  78.         JulianDate dtSettle = DateUtil.CreateFromYMD (
  79.             2015,
  80.             DateUtil.DECEMBER,
  81.             1
  82.         );

  83.         JSONObject jsonParameters = new JSONObject();

  84.         jsonParameters.put ("Name", "FPMG 11.89 2019");

  85.         jsonParameters.put ("SettleDate", dtSettle.toString());

  86.         jsonParameters.put ("EffectiveDate", dtEffective.toString());

  87.         jsonParameters.put ("BeginPrincipalFactor", dblBeginPrincipalFactor);

  88.         jsonParameters.put ("CouponRate", dblCouponRate);

  89.         jsonParameters.put ("ServiceFeeRate", dblServiceFeeRate);

  90.         jsonParameters.put ("CPR", dblCPR);

  91.         jsonParameters.put ("BondNotional", dblBondNotional);

  92.         jsonParameters.put ("DayCount", strDayCount);

  93.         jsonParameters.put ("NumPayment", iNumPayment);

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

  95.         jsonParameters.put ("PayFrequency", iPayFrequency);

  96.         jsonParameters.put ("FixedMonthlyAmount", dblFixedMonthlyAmount);

  97.         JSONObject jsonRequest = new JSONObject();

  98.         jsonRequest.put ("API", "PREPAYASSETBACKED::SECULARMETRICS");

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

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

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

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

  103.         System.out.println (KeyHoleSkeleton.Thunker (jsonRequest.toJSONString()));
  104.     }
  105. }