BillTotalReturnSwapDefinition extends TotalReturnSwapDefinition { @Override public BillTotalReturnSwap toDerivative(final ZonedDateTime date, final ZonedDateTimeDoubleTimeSeries data) { final double effectiveTime = TimeCalculator.getTimeBetween(date, getEffectiveDate()); final double terminationTime = TimeCalculator.getTimeBetween(date, getTerminationDate()); final Annuity<? extends Payment> fundingLeg = getFundingLeg().toDerivative(date, data); BillSecurity bill = getAsset().toDerivative(date, getEffectiveDate()); return new BillTotalReturnSwap(effectiveTime, terminationTime, fundingLeg, bill, _quantity); } BillTotalReturnSwapDefinition(final ZonedDateTime effectiveDate, final ZonedDateTime terminationDate,
      final AnnuityDefinition<? extends PaymentDefinition> annuity,
      final BillSecurityDefinition bill, final double quantity); @Override BillSecurityDefinition getAsset(); double getQuantity(); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor); @Override BillTotalReturnSwap toDerivative(final ZonedDateTime date, final ZonedDateTimeDoubleTimeSeries data); @Override BillTotalReturnSwap toDerivative(final ZonedDateTime date);  }
@Test public void toDerivativeFixedRecBeforeEffectiveDate() { double effectiveTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_1, EFFECTIVE_DATE); double terminationTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_1, TERMINATION_DATE); Annuity<? extends Payment> fundingLeg = FUNDING_LEG_FIXED_PAY_DEFINITION.toDerivative(REFERENCE_DATE_1); BillSecurity bond = BELDEC14_DEFINITION.toDerivative(REFERENCE_DATE_1, EFFECTIVE_DATE); BillTotalReturnSwap trsExpected = new BillTotalReturnSwap(effectiveTime, terminationTime, fundingLeg, bond, NOTIONAL_BILL); BillTotalReturnSwap trsConverted = TRS_REC_FIXED_PAY_DEFINITION.toDerivative(REFERENCE_DATE_1); assertEquals("BillTotalReturnSwapDefinition: toDerivative", trsExpected, trsConverted); }
@Test public void toDerivativeFixedPayBeforeEffectiveDate() { double effectiveTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_1, EFFECTIVE_DATE); double terminationTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_1, TERMINATION_DATE); Annuity<? extends Payment> fundingLeg = FUNDING_LEG_FIXED_REC_DEFINITION.toDerivative(REFERENCE_DATE_1); BillSecurity bond = BELDEC14_DEFINITION.toDerivative(REFERENCE_DATE_1, EFFECTIVE_DATE); BillTotalReturnSwap trsExpected = new BillTotalReturnSwap(effectiveTime, terminationTime, fundingLeg, bond, -NOTIONAL_BILL); BillTotalReturnSwap trsConverted = TRS_PAY_FIXED_REC_DEFINITION.toDerivative(REFERENCE_DATE_1); assertEquals("BondTotalReturnSwapDefinition: toDerivative", trsExpected, trsConverted); }
@Test public void toDerivativeFixedAfterEffectiveDate() { double effectiveTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_2, EFFECTIVE_DATE); double terminationTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_2, TERMINATION_DATE); Annuity<? extends Payment> fundingLeg = FUNDING_LEG_FIXED_PAY_DEFINITION.toDerivative(REFERENCE_DATE_2); BillSecurity bond = BELDEC14_DEFINITION.toDerivative(REFERENCE_DATE_2, EFFECTIVE_DATE); BillTotalReturnSwap trsExpected = new BillTotalReturnSwap(effectiveTime, terminationTime, fundingLeg, bond, NOTIONAL_BILL); BillTotalReturnSwap trsConverted = TRS_REC_FIXED_PAY_DEFINITION.toDerivative(REFERENCE_DATE_2); assertEquals("BondTotalReturnSwapDefinition: toDerivative", trsExpected, trsConverted); }
@Test public void toDerivativeIborBeforeEffectiveDate() { double effectiveTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_1, EFFECTIVE_DATE); double terminationTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_1, TERMINATION_DATE); Annuity<? extends Payment> fundingLeg = FUNDING_LEG_IBOR_PAY_DEFINITION.toDerivative(REFERENCE_DATE_1, FIXING_TS); BillSecurity bond = BELDEC14_DEFINITION.toDerivative(REFERENCE_DATE_1, EFFECTIVE_DATE); BillTotalReturnSwap trsExpected = new BillTotalReturnSwap(effectiveTime, terminationTime, fundingLeg, bond, NOTIONAL_BILL); BillTotalReturnSwap trsConverted = TRS_REC_IBOR_PAY_DEFINITION.toDerivative(REFERENCE_DATE_1, FIXING_TS); assertEquals("BondTotalReturnSwapDefinition: toDerivative", trsExpected, trsConverted); }
@Test public void toDerivativeIborAfterEffectiveDate() { double effectiveTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_2, EFFECTIVE_DATE); double terminationTime = TimeCalculator.getTimeBetween(REFERENCE_DATE_2, TERMINATION_DATE); Annuity<? extends Payment> fundingLeg = FUNDING_LEG_IBOR_PAY_DEFINITION.toDerivative(REFERENCE_DATE_2, FIXING_TS); BillSecurity bond = BELDEC14_DEFINITION.toDerivative(REFERENCE_DATE_2, EFFECTIVE_DATE); BillTotalReturnSwap trsExpected = new BillTotalReturnSwap(effectiveTime, terminationTime, fundingLeg, bond, NOTIONAL_BILL); BillTotalReturnSwap trsConverted = TRS_REC_IBOR_PAY_DEFINITION.toDerivative(REFERENCE_DATE_2, FIXING_TS); assertEquals("BondTotalReturnSwapDefinition: toDerivative", trsExpected, trsConverted); }