@Override public java.lang.String getComponentName() { return "FloatingStream=" + org.drip.analytics.date.JulianDate.fromJulian(_dblMaturity); }
private static final void CDSAPISample() throws Exception { JulianDate dtStart = JulianDate.Today(); /* * Flat Discount Curve */ DiscountCurve dc = DiscountCurveBuilder.CreateFromFlatRate(dtStart, "USD", 0.05); /* * Flat Credit Curve */ CreditCurve cc = CreditCurveBuilder.FromFlatHazard(dtStart.getJulian(), "CC", "USD", 0.02, 0.4); /* * Component Market Parameters built from the Discount and the Credit Curves */ ComponentMarketParams cmp = ComponentMarketParamsBuilder.MakeCreditCMP(dc, cc); /* * Create an SNAC CDS */ CreditDefaultSwap cds = CDSBuilder.CreateSNAC(dtStart, "5Y", 0.1, "CC"); /* * Valuation Parameters */ ValuationParams valParams = ValuationParams.CreateValParams(dtStart, 0, "", Convention.DR_ACTUAL); /* * Standard Credit Pricer Parameters (check javadoc for details) */ PricerParams pricerParams = PricerParams.MakeStdPricerParams(); System.out.println( "Acc Start Acc End Pay Date Index Spread Cpn DCF Pay01 Surv01"); System.out.println( "--------- --------- --------- ------ ------ -------- --------- --------"); /* * CDS Coupon Cash Flow */ for (CashflowPeriodCurveFactors p : cds.getCouponFlow(valParams, pricerParams, cmp)) System.out.println( JulianDate.fromJulian(p.getAccrualStartDate()) + FIELD_SEPARATOR + JulianDate.fromJulian(p.getAccrualEndDate()) + FIELD_SEPARATOR + JulianDate.fromJulian(p.getPayDate()) + FIELD_SEPARATOR + FormatUtil.FormatDouble(p.getIndexRate(), 1, 4, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(p.getSpread(), 1, 4, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(p.getCouponDCF(), 1, 4, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(dc.df(p.getPayDate()), 1, 4, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(cc.getSurvival(p.getPayDate()), 1, 4, 1.)); System.out.println( "Loss Start Loss End Pay Date Cpn Notl Rec EffDF StartSurv EndSurv"); System.out.println( "---------- -------- -------- --- ---- --- ----- --------- -------"); /* * CDS Loss Cash Flow */ for (LossPeriodCurveFactors dp : cds.getLossFlow(valParams, pricerParams, cmp)) System.out.println( JulianDate.fromJulian(dp.getStartDate()) + FIELD_SEPARATOR + JulianDate.fromJulian(dp.getEndDate()) + FIELD_SEPARATOR + JulianDate.fromJulian(dp.getPayDate()) + FIELD_SEPARATOR + FormatUtil.FormatDouble(dp.getCouponDCF(), 1, 4, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(dp.effectiveNotional(), 1, 0, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(dp.effectiveRecovery(), 1, 2, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(dp.effectiveDF(), 1, 4, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(dp.startSurvival(), 1, 4, 1.) + FIELD_SEPARATOR + FormatUtil.FormatDouble(dp.endSurvival(), 1, 4, 1.)); }