private static final void CreditCurveEODAPISample() throws Exception { JulianDate dt = JulianDate.CreateFromYMD(2011, 7, 21); /* * Retrieves all the CDS curves available for the given EOD */ Set<String> setstrCDSCurves = CreditAnalytics.GetEODCDSCurveNames(dt); for (String strCDSCurveName : setstrCDSCurves) System.out.println(strCDSCurveName); /* * Retrieves the calibrated credit curve from the CDS instruments for the given CDS curve name, * IR curve name, and EOD. Also shows the 10Y survival probability and hazard rate. */ CreditCurve ccEOD = CreditAnalytics.LoadEODCDSCreditCurve("813796", "USD", dt); JulianDate dt10Y = JulianDate.Today().addYears(10); System.out.println( "CCFromEOD[" + dt10Y.toString() + "]; Survival=" + ccEOD.getSurvival("10Y") + "; Hazard=" + ccEOD.calcHazard("10Y")); /* * Displays the CDS quotes used to construct the closing credit curve */ CalibratableComponent[] aCompCDS = ccEOD.calibComp(); for (int i = 0; i < aCompCDS.length; ++i) System.out.println( aCompCDS[i].getPrimaryCode() + " => " + (int) (ccEOD.manifestMeasure(aCompCDS[i].getPrimaryCode()))); /* * Loads all available credit curves for the given curve ID built from CDS instruments between 2 dates */ Map<JulianDate, CreditCurve> mapCC = CreditAnalytics.LoadEODCDSCreditCurves( "813796", "USD", JulianDate.CreateFromYMD(2011, 7, 14), dt); /* * Displays their 5Y CDS quote */ for (Map.Entry<JulianDate, CreditCurve> meCC : mapCC.entrySet()) { JulianDate dtME = meCC.getKey(); CreditCurve ccCOB = meCC.getValue(); System.out.println(dtME + "[CDS.5Y] => " + (int) (ccCOB.manifestMeasure("CDS.5Y"))); } }
private static final void CDSEODMeasuresAPISample() { JulianDate dtEOD = JulianDate.CreateFromYMD(2011, 7, 21); // EOD /* * Create a spot starting CDS based off of a specific credit curve */ CreditDefaultSwap cds = CDSBuilder.CreateSNAC(JulianDate.Today(), "5Y", 0.1, "813796"); /* * Calculate the EOD CDS measures */ CaseInsensitiveTreeMap<Double> mapEODCDSMeasures = CreditAnalytics.GetEODCDSMeasures(cds, dtEOD); /* * Display the EOD CDS measures */ for (Map.Entry<String, Double> me : mapEODCDSMeasures.entrySet()) System.out.println(me.getKey() + " => " + me.getValue()); }