IndexOptionPricer { public double getOptionPremium(final double defaultAdjIndexValue, final double vol, final IndexOptionStrike strike, final boolean isPayer) { ArgumentChecker.notNull(strike, "strike"); if (strike instanceof SpreadBasedStrike) { return getOptionPriceForSpreadQuotedIndex(defaultAdjIndexValue, vol, strike.amount(), isPayer); } else if (strike instanceof ExerciseAmount) { return getOptionPriceForPriceQuotedIndex(defaultAdjIndexValue, vol, strike.amount(), isPayer); } else { throw new IllegalArgumentException("unknow strike type " + strike.getClass()); } } IndexOptionPricer(final CDSAnalytic fwdCDS, final double timeToExpiry, final ISDACompliantYieldCurve yieldCurve, final double coupon);  IndexOptionPricer(final CDSAnalytic fwdCDS, final double timeToExpiry, final ISDACompliantYieldCurve yieldCurve, final double coupon, final boolean useExactAnnuityCal); double getOptionPremium(final double defaultAdjIndexValue, final double vol, final IndexOptionStrike strike, final boolean isPayer); double getOptionPriceForSpreadQuotedIndex(final double defaultAdjIndexValue, final double vol, final double strike, final boolean isPayer); double getOptionPriceForPriceQuotedIndex(final double defaultAdjIndexValue, final double vol, final double gK, final boolean isPayer); double impliedVol(final double atmFwd, final double gK, final double price, final boolean isPayer); double calibrateX0(final double defaultAdjIndexValue, final double vol); Function1D<Double, Double> getDefaultAdjForwardForX(final double coupon);  }
@Test public void putCallTest() { final LocalDate optionExpiry = TRADE_DATE.plusMonths(1); final CDSAnalytic fwdCDS = FACTORY.makeIMMCDS(TRADE_DATE, Period.ofYears(5)); final CDSAnalytic fwdStartingCDS = FACTORY.makeForwardStartingIMMCDS(TRADE_DATE, optionExpiry, Period.ofYears(5)); final double expiry = ACT365F.getDayCountFraction(TRADE_DATE, optionExpiry); final double atmFwd = -0.02; final IndexOptionPricer pricer = new IndexOptionPricer(fwdCDS, expiry, YIELD_CURVE, INDEX_COUPON); final double vol = 0.34; final double df = YIELD_CURVE.getDiscountFactor(fwdStartingCDS.getCashSettleTime()); for (int i = 0; i < 20; i++) { final double exercisePrice = -0.04 + 0.1 * i / 19.; final double putCall = df * (atmFwd - exercisePrice); final double payer = pricer.getOptionPremium(atmFwd, vol, new ExerciseAmount(exercisePrice), true); final double reciver = pricer.getOptionPremium(atmFwd, vol, new ExerciseAmount(exercisePrice), false); assertEquals(payer - reciver, putCall, 1e-12); } }