private static final void CustomForwardCurveBuilderSample() throws Exception { /* * Initialize the Credit Analytics Library */ CreditAnalytics.Init(""); String strCurrency = "AUD"; JulianDate dtToday = DateUtil.Today().addTenor("0D"); /* * Construct the Discount Curve using its instruments and quotes */ DiscountCurve dc = MakeDC(dtToday, strCurrency); System.out.println("\n------------------------------------------------------------"); System.out.println("------------------- 1M-6M Basis Swap -----------------"); /* * Build and run the sampling for the 1M-6M Tenor Basis Swap from its instruments and quotes. */ Map<String, ForwardCurve> mapForward1M6M = xM6MBasisSample( dtToday, strCurrency, dc, 1, new String[] { "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y" }, new double[] { 0.00551, // 1Y 0.00387, // 2Y 0.00298, // 3Y 0.00247, // 4Y 0.00211, // 5Y 0.00185, // 6Y 0.00165, // 7Y 0.00150, // 8Y 0.00137, // 9Y 0.00127, // 10Y 0.00119, // 11Y 0.00112, // 12Y 0.00096, // 15Y 0.00079, // 20Y 0.00069, // 25Y 0.00062 // 30Y }); /* * Build and run the sampling for the 3M-6M Tenor Basis Swap from its instruments and quotes. */ System.out.println("\n------------------------------------------------------------"); System.out.println("------------------- 3M-6M Basis Swap -----------------"); Map<String, ForwardCurve> mapForward3M6M = xM6MBasisSample( dtToday, strCurrency, dc, 3, new String[] { "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y" }, new double[] { 0.00186, // 1Y 0.00127, // 2Y 0.00097, // 3Y 0.00080, // 4Y 0.00067, // 5Y 0.00058, // 6Y 0.00051, // 7Y 0.00046, // 8Y 0.00042, // 9Y 0.00038, // 10Y 0.00035, // 11Y 0.00033, // 12Y 0.00028, // 15Y 0.00022, // 20Y 0.00020, // 25Y 0.00018 // 30Y }); /* * Build and run the sampling for the 12M-6M Tenor Basis Swap from its instruments and quotes. */ System.out.println("\n------------------------------------------------------------"); System.out.println("------------------- 12M-6M Basis Swap -----------------"); Map<String, ForwardCurve> mapForward12M6M = xM6MBasisSample( dtToday, strCurrency, dc, 12, new String[] { "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "35Y", "40Y" }, new double[] { -0.00212, // 1Y -0.00152, // 2Y -0.00117, // 3Y -0.00097, // 4Y -0.00082, // 5Y -0.00072, // 6Y -0.00063, // 7Y -0.00057, // 8Y -0.00051, // 9Y -0.00047, // 10Y -0.00044, // 11Y -0.00041, // 12Y -0.00035, // 15Y -0.00028, // 20Y -0.00025, // 25Y -0.00022, // 30Y -0.00022, // 35Y Extrapolated -0.00022, // 40Y Extrapolated }); System.out.println( "\n--------------------------------------------------------------------------------------------------------------------------------------------"); System.out.println( "------------------------------------------------------- 1M-6M Micro Jack -------------------------------------------------------------------"); System.out.println( "--------------------------------------------------------------------------------------------------------------------------------------------\n"); ForwardJack(dtToday, mapForward1M6M); System.out.println( "\n--------------------------------------------------------------------------------------------------------------------------------------------"); System.out.println( "------------------------------------------------------- 3M-6M Micro Jack -------------------------------------------------------------------"); System.out.println( "--------------------------------------------------------------------------------------------------------------------------------------------\n"); ForwardJack(dtToday, mapForward3M6M); System.out.println( "\n--------------------------------------------------------------------------------------------------------------------------------------------"); System.out.println( "------------------------------------------------------ 12M-6M Micro Jack -------------------------------------------------------------------"); System.out.println( "--------------------------------------------------------------------------------------------------------------------------------------------\n"); ForwardJack(dtToday, mapForward12M6M); }
public static final void main(final String[] astrArgs) throws Exception { /* * Initialize the Credit Analytics Library */ CreditAnalytics.Init(""); JulianDate dtToday = DateUtil.Today(); String[] astrTenor = new String[] { "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y" }; double[] adblBasis = new double[] { 0.00186, // 1Y 0.00127, // 2Y 0.00097, // 3Y 0.00080, // 4Y 0.00067, // 5Y 0.00058, // 6Y 0.00051, // 7Y 0.00046, // 8Y 0.00042, // 9Y 0.00038, // 10Y 0.00035, // 11Y 0.00033, // 12Y 0.00028, // 15Y 0.00022, // 20Y 0.00020, // 25Y 0.00018 // 30Y }; BasisCurve bcCubicPolynomial = ScenarioBasisCurveBuilder.CubicPolynomialBasisCurve( "USD3M6MBasis_CubicPolynomial", dtToday, ForwardLabel.Create("USD", "6M"), ForwardLabel.Create("USD", "3M"), false, new CollateralizationParams("OVERNIGHT", "USD"), astrTenor, adblBasis); BasisCurve bcQuinticPolynomial = ScenarioBasisCurveBuilder.QuarticPolynomialBasisCurve( "USD3M6MBasis_QuinticPolynomial", dtToday, ForwardLabel.Create("USD", "6M"), ForwardLabel.Create("USD", "3M"), false, new CollateralizationParams("OVERNIGHT", "USD"), astrTenor, adblBasis); BasisCurve bcKaklisPandelis = ScenarioBasisCurveBuilder.KaklisPandelisBasisCurve( "USD3M6MBasis_KaklisPandelis", dtToday, ForwardLabel.Create("USD", "6M"), ForwardLabel.Create("USD", "3M"), false, new CollateralizationParams("OVERNIGHT", "USD"), astrTenor, adblBasis); BasisCurve bcKLKHyperbolic = ScenarioBasisCurveBuilder.KLKHyperbolicBasisCurve( "USD3M6MBasis_KLKHyperbolic", dtToday, ForwardLabel.Create("USD", "6M"), ForwardLabel.Create("USD", "3M"), false, new CollateralizationParams("OVERNIGHT", "USD"), astrTenor, adblBasis, 1.); BasisCurve bcKLKRationalLinear = ScenarioBasisCurveBuilder.KLKRationalLinearBasisCurve( "USD3M6MBasis_KLKRationalLinear", dtToday, ForwardLabel.Create("USD", "6M"), ForwardLabel.Create("USD", "3M"), false, new CollateralizationParams("OVERNIGHT", "USD"), astrTenor, adblBasis, 0.1); BasisCurve bcKLKRationalQuadratic = ScenarioBasisCurveBuilder.KLKRationalLinearBasisCurve( "USD3M6MBasis_KLKRationalQuadratic", dtToday, ForwardLabel.Create("USD", "6M"), ForwardLabel.Create("USD", "3M"), false, new CollateralizationParams("OVERNIGHT", "USD"), astrTenor, adblBasis, 2.); System.out.println("\tPrinting the Basis Node Values in Order (Left -> Right):"); System.out.println("\t\tCalculated Cubic Polynomial Basis (%)"); System.out.println("\t\tCalculated Quintic Polynomial Basis (%)"); System.out.println("\t\tCalculated Kaklis Pandelis Basis (%)"); System.out.println("\t\tCalculated KLK Hyperbolic Basis (%)"); System.out.println("\t\tCalculated KLK Rational Linear Basis (%)"); System.out.println("\t\tCalculated KLK Rational Quadratic Basis (%)"); System.out.println("\t\tInput Quote (bp)"); System.out.println("\t-------------------------------------------------------------"); System.out.println("\t-------------------------------------------------------------"); for (int i = 0; i < adblBasis.length; ++i) System.out.println( "\t" + astrTenor[i] + " => " + FormatUtil.FormatDouble(bcCubicPolynomial.basis(astrTenor[i]), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcQuinticPolynomial.basis(astrTenor[i]), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcKaklisPandelis.basis(astrTenor[i]), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcKLKHyperbolic.basis(astrTenor[i]), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcKLKRationalLinear.basis(astrTenor[i]), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcKLKRationalQuadratic.basis(astrTenor[i]), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(adblBasis[i], 1, 2, 10000.)); System.out.println( "\n\t|----------------------------------------------------------------------------|"); System.out.println( "\t| DATE => CUBIC | QUINTIC | KAKPAND | KLKHYPER | KLKRATLNR | KLKRATQUA |"); System.out.println( "\t|----------------------------------------------------------------------------|\n"); for (int i = 3; i < 30; ++i) { JulianDate dt = dtToday.addTenor(i + "Y"); System.out.println( "\t" + dt + " => " + FormatUtil.FormatDouble(bcCubicPolynomial.basis(dt), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcQuinticPolynomial.basis(dt), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcKaklisPandelis.basis(dt), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcKLKHyperbolic.basis(dt), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcKLKRationalLinear.basis(dt), 1, 2, 10000.) + " | " + FormatUtil.FormatDouble(bcKLKRationalQuadratic.basis(dt), 1, 2, 10000.) + " | "); } System.out.println( "\n\t|----------------------------------------------------------------------------|"); }