BondFutureConstantSpreadHorizonCalculator extends HorizonCalculator<BondFuturesTransactionDefinition, IssuerProviderInterface, Double> { @Override public MultipleCurrencyAmount getTheta(final BondFuturesTransactionDefinition definition, final ZonedDateTime date, final IssuerProviderInterface data, final int daysForward, final Calendar calendar) { throw new UnsupportedOperationException("Must supply a last margin price"); } private  BondFutureConstantSpreadHorizonCalculator(); static HorizonCalculator<BondFuturesTransactionDefinition, IssuerProviderInterface, Double> getInstance(); @Override MultipleCurrencyAmount getTheta(final BondFuturesTransactionDefinition definition, final ZonedDateTime date, final IssuerProviderInterface data,
      final int daysForward, final Calendar calendar); @Override MultipleCurrencyAmount getTheta(final BondFuturesTransactionDefinition definition, final ZonedDateTime date, final IssuerProviderInterface data,
      final int daysForward, final Calendar calendar, final Double lastMarginPrice);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDefinition() { CALCULATOR.getTheta(null, HORIZON_DATE, FLAT_ISSUER_MULTICURVES, 1, CALENDAR, 1.01); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDate() { CALCULATOR.getTheta(TRANSACTION, null, FLAT_ISSUER_MULTICURVES, 1, CALENDAR, 1.01); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { CALCULATOR.getTheta(TRANSACTION, HORIZON_DATE, null, 1, CALENDAR, 1.01); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDaysForward1() { CALCULATOR.getTheta(TRANSACTION, HORIZON_DATE, FLAT_ISSUER_MULTICURVES, 2, CALENDAR, 1.01); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDaysForward2() { CALCULATOR.getTheta(TRANSACTION, HORIZON_DATE, FLAT_ISSUER_MULTICURVES, -2, CALENDAR, 1.01); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testNoMarginPrice() { CALCULATOR.getTheta(TRANSACTION, HORIZON_DATE, FLAT_ISSUER_MULTICURVES, 2, CALENDAR); }
@Test public void testConstantMarginPrice() { final BondFuturesTransaction today = TRANSACTION.toDerivative(HORIZON_DATE, REFERENCE_PRICE); final BondFuturesTransaction tomorrow = TRANSACTION.toDerivative(HORIZON_DATE.plusDays(1), REFERENCE_PRICE); final MultipleCurrencyAmount pvToday = today.accept(PV_CALCULATOR, FLAT_ISSUER_MULTICURVES); final MultipleCurrencyAmount pvTomorrow = tomorrow.accept(PV_CALCULATOR, FLAT_ISSUER_MULTICURVES); MultipleCurrencyAmount expected = HorizonCalculator.subtract(pvTomorrow, pvToday); MultipleCurrencyAmount actual = CALCULATOR.getTheta(TRANSACTION, HORIZON_DATE, FLAT_ISSUER_MULTICURVES, 1, CALENDAR, REFERENCE_PRICE); assertMCAEquals(expected, actual); final BondFuturesTransaction yesterday = TRANSACTION.toDerivative(HORIZON_DATE.minusDays(1), REFERENCE_PRICE); final MultipleCurrencyAmount pvYesterday = yesterday.accept(PV_CALCULATOR, FLAT_ISSUER_MULTICURVES); expected = HorizonCalculator.subtract(pvYesterday, pvToday); actual = CALCULATOR.getTheta(TRANSACTION, HORIZON_DATE, FLAT_ISSUER_MULTICURVES, -1, CALENDAR, REFERENCE_PRICE); assertMCAEquals(expected, actual); }