/**
 * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.analytics.model.credit;


import org.threeten.bp.ZonedDateTime;

import com.opengamma.analytics.financial.credit.PriceType;
import com.opengamma.analytics.financial.credit.creditdefaultswap.definition.legacy.LegacyVanillaCreditDefaultSwapDefinition;
import com.opengamma.analytics.financial.credit.creditdefaultswap.pricing.vanilla.PresentValueCreditDefaultSwap;
import com.opengamma.analytics.financial.credit.isdayieldcurve.ISDADateCurve;
import com.opengamma.engine.value.ValueRequirementNames;

/**
 * Function to calculate the upfront amount for a given CDS instrument.
 */
public class ISDAUpfrontAmountVanillaCDSFunction extends ISDAVanillaCDSFunction {

  private static PresentValueCreditDefaultSwap CALCULATOR = new PresentValueCreditDefaultSwap();

  public ISDAUpfrontAmountVanillaCDSFunction() {
    super(ValueRequirementNames.UPFRONT_AMOUNT);
  }

  @Override
  protected Object compute(final ZonedDateTime now, LegacyVanillaCreditDefaultSwapDefinition cds, final double[] spreads, final ISDADateCurve isdaCurve, final ZonedDateTime[] bucketDates) {
    final ZonedDateTime[] singleCalibrationTenor = { cds.getMaturityDate() };
    final double[] singleSpreadTermStructure = { spreads[0] };
    double points = CALCULATOR.calibrateAndGetPresentValue(now, cds, singleCalibrationTenor, singleSpreadTermStructure, isdaCurve, PriceType.CLEAN); // take values from requirements
    return 100.0 * points;
  }

}

@@ -1377,23 +1377,14 @@
     
-double points =
+return
  CAL
@@ -1505,13 +1505,13 @@
 ype.
-CLEAN
+DIRTY
 ); /
@@ -1546,35 +1546,8 @@
 nts%0A
-    return 100.0 * points;%0A
   %7D%0A

Correct upfront amount calculation