//------------------------------------------------------------------------- public virtual void test_builder_full() { ImmutableTermDepositConvention test = ImmutableTermDepositConvention.builder().name("Test").businessDayAdjustment(BDA_MOD_FOLLOW).currency(EUR).dayCount(ACT_360).spotDateOffset(PLUS_TWO_DAYS).build(); assertEquals(test.Name, "Test"); assertEquals(test.BusinessDayAdjustment, BDA_MOD_FOLLOW); assertEquals(test.Currency, EUR); assertEquals(test.DayCount, ACT_360); assertEquals(test.SpotDateOffset, PLUS_TWO_DAYS); }
//------------------------------------------------------------------------- public virtual void test_toTrade() { TermDepositConvention convention = ImmutableTermDepositConvention.builder().name("EUR-Dep").businessDayAdjustment(BDA_MOD_FOLLOW).currency(EUR).dayCount(ACT_360).spotDateOffset(PLUS_TWO_DAYS).build(); LocalDate tradeDate = LocalDate.of(2015, 1, 22); Period period3M = Period.ofMonths(3); BuySell buy = BuySell.BUY; double notional = 2_000_000d; double rate = 0.0125; TermDepositTrade trade = convention.createTrade(tradeDate, period3M, buy, notional, rate, REF_DATA); LocalDate startDateExpected = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA); LocalDate endDateExpected = startDateExpected.plus(period3M); TermDeposit termDepositExpected = TermDeposit.builder().buySell(buy).currency(EUR).notional(notional).startDate(startDateExpected).endDate(endDateExpected).businessDayAdjustment(BDA_MOD_FOLLOW).rate(rate).dayCount(ACT_360).build(); TradeInfo tradeInfoExpected = TradeInfo.of(tradeDate); assertEquals(trade.Product, termDepositExpected); assertEquals(trade.Info, tradeInfoExpected); }
//----------------------------------------------------------------------- /// <summary> /// Obtains a convention based on the specified currency, business day adjustment, /// day count convention and spot date offset. /// </summary> /// <param name="name"> the name of the convention, such as 'GBP-Deposit-ON' </param> /// <param name="currency"> the currency, in which the payments are made </param> /// <param name="businessDayAdjustment"> the business day adjustment to apply to the start and end date </param> /// <param name="dayCount"> the day count convention, used to convert dates to a numerical value </param> /// <param name="spotDateOffset"> the offset of the spot value date from the trade date </param> /// <returns> the convention </returns> public static ImmutableTermDepositConvention of(string name, Currency currency, BusinessDayAdjustment businessDayAdjustment, DayCount dayCount, DaysAdjustment spotDateOffset) { return(ImmutableTermDepositConvention.builder().name(name).currency(currency).businessDayAdjustment(businessDayAdjustment).dayCount(dayCount).spotDateOffset(spotDateOffset).build()); }