// calculate the last fixing date private LocalDate calculateLastFixingDate(LocalDate valuationDate, ReferenceData refData) { IborFixingDepositTrade trade = template.createTrade(valuationDate, BuySell.BUY, 0d, 0d, refData); ResolvedIborFixingDeposit deposit = trade.Product.resolve(refData); return(deposit.FloatingRate.FixingDate); }
public IborFixingDepositTrade toTrade(TradeInfo tradeInfo, LocalDate startDate, LocalDate endDate, BuySell buySell, double notional, double fixedRate) { Optional <LocalDate> tradeDate = tradeInfo.TradeDate; if (tradeDate.Present) { ArgChecker.inOrderOrEqual(tradeDate.get(), startDate, "tradeDate", "startDate"); } return(IborFixingDepositTrade.builder().info(tradeInfo).product(IborFixingDeposit.builder().buySell(buySell).currency(Currency).notional(notional).startDate(startDate).endDate(endDate).businessDayAdjustment(BusinessDayAdjustment).fixedRate(fixedRate).index(index).fixingDateOffset(FixingDateOffset).dayCount(DayCount).build()).build()); }
public virtual void test_metadata_last_fixing() { IborFixingDepositCurveNode node = IborFixingDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD).withDate(CurveNodeDate.LAST_FIXING); ImmutableMarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, 0.0d).build(); IborFixingDepositTrade trade = node.trade(1d, marketData, REF_DATA); ResolvedIborFixingDeposit product = trade.Product.resolve(REF_DATA); LocalDate fixingDate = ((IborRateComputation)product.FloatingRate).FixingDate; DatedParameterMetadata metadata = node.metadata(VAL_DATE, REF_DATA); assertEquals(((TenorDateParameterMetadata)metadata).Date, fixingDate); assertEquals(((TenorDateParameterMetadata)metadata).Tenor.Period, TEMPLATE.DepositPeriod); }
public virtual void test_createTrade() { IborFixingDepositTemplate template = IborFixingDepositTemplate.of(EUR_LIBOR_3M); double notional = 1d; double fixedRate = 0.045; LocalDate tradeDate = LocalDate.of(2015, 1, 22); IborFixingDepositTrade trade = template.createTrade(tradeDate, BUY, notional, fixedRate, REF_DATA); ImmutableIborFixingDepositConvention conv = (ImmutableIborFixingDepositConvention)template.Convention; LocalDate startExpected = conv.SpotDateOffset.adjust(tradeDate, REF_DATA); LocalDate endExpected = startExpected.plus(template.DepositPeriod); IborFixingDeposit productExpected = IborFixingDeposit.builder().businessDayAdjustment(conv.BusinessDayAdjustment).buySell(BUY).startDate(startExpected).endDate(endExpected).fixedRate(fixedRate).index(EUR_LIBOR_3M).notional(notional).build(); TradeInfo tradeInfoExpected = TradeInfo.builder().tradeDate(tradeDate).build(); assertEquals(trade.Info, tradeInfoExpected); assertEquals(trade.Product, productExpected); }
public virtual void test_trade() { IborFixingDepositCurveNode node = IborFixingDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); LocalDate valuationDate = LocalDate.of(2015, 1, 22); double rate = 0.035; MarketData marketData = ImmutableMarketData.builder(valuationDate).addValue(QUOTE_ID, rate).build(); IborFixingDepositTrade trade = node.trade(1d, marketData, REF_DATA); ImmutableIborFixingDepositConvention conv = (ImmutableIborFixingDepositConvention)TEMPLATE.Convention; LocalDate startDateExpected = conv.SpotDateOffset.adjust(valuationDate, REF_DATA); LocalDate endDateExpected = startDateExpected.plus(TEMPLATE.DepositPeriod); IborFixingDeposit depositExpected = IborFixingDeposit.builder().buySell(BuySell.BUY).index(EUR_LIBOR_3M).startDate(startDateExpected).endDate(endDateExpected).businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUR_LIBOR_3M.FixingCalendar)).notional(1.0d).fixedRate(rate + SPREAD).build(); TradeInfo tradeInfoExpected = TradeInfo.builder().tradeDate(valuationDate).build(); assertEquals(trade.Product, depositExpected); assertEquals(trade.Info, tradeInfoExpected); }
//------------------------------------------------------------------------- public virtual void test_toTrade() { IborFixingDepositConvention convention = ImmutableIborFixingDepositConvention.builder().businessDayAdjustment(BDA_MOD_FOLLOW).currency(EUR).dayCount(ACT_365F).fixingDateOffset(FIXING_ADJ).index(EUR_LIBOR_3M).spotDateOffset(SPOT_ADJ).build(); LocalDate tradeDate = LocalDate.of(2015, 1, 22); Period depositPeriod = Period.ofMonths(3); double notional = 1d; double fixedRate = 0.045; IborFixingDepositTrade trade = convention.createTrade(tradeDate, depositPeriod, BUY, notional, fixedRate, REF_DATA); LocalDate startExpected = SPOT_ADJ.adjust(tradeDate, REF_DATA); LocalDate endExpected = startExpected.plus(depositPeriod); IborFixingDeposit productExpected = IborFixingDeposit.builder().businessDayAdjustment(BDA_MOD_FOLLOW).buySell(BUY).currency(EUR).dayCount(ACT_365F).startDate(startExpected).endDate(endExpected).fixedRate(fixedRate).fixingDateOffset(FIXING_ADJ).index(EUR_LIBOR_3M).notional(notional).build(); TradeInfo tradeInfoExpected = TradeInfo.builder().tradeDate(tradeDate).build(); assertEquals(trade.Product, productExpected); assertEquals(trade.Info, tradeInfoExpected); }