/** * Obtains an instance representing an amount where the date is fixed. * <p> * Whether the payment is pay or receive is determined by the sign of the specified amount. * * @param value the amount of the payment * @param date the date that the payment is made * @return the adjustable payment instance */ public static AdjustablePayment of(CurrencyAmount value, LocalDate date) { return new AdjustablePayment(value, AdjustableDate.of(date)); }
public void test_of_2args_withNoAdjustment() { AdjustableDate test = AdjustableDate.of(FRI_2014_07_11, BDA_NONE); assertEquals(test.getUnadjusted(), FRI_2014_07_11); assertEquals(test.getAdjustment(), BDA_NONE); assertEquals(test.toString(), "2014-07-11"); assertEquals(test.adjusted(REF_DATA), FRI_2014_07_11); }
@Override public AdjustableDate build() { return new AdjustableDate( unadjusted, adjustment); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 482476551: // unadjusted return ((AdjustableDate) bean).getUnadjusted(); case 1977085293: // adjustment return ((AdjustableDate) bean).getAdjustment(); } return super.propertyGet(bean, propertyName, quiet); }
public void equals() { AdjustableDate a1 = AdjustableDate.of(FRI_2014_07_11, BDA_FOLLOW_SAT_SUN); AdjustableDate a2 = AdjustableDate.of(FRI_2014_07_11, BDA_FOLLOW_SAT_SUN); AdjustableDate b = AdjustableDate.of(SAT_2014_07_12, BDA_FOLLOW_SAT_SUN); AdjustableDate c = AdjustableDate.of(FRI_2014_07_11, BDA_NONE); assertEquals(a1.equals(a2), true); assertEquals(a1.equals(b), false); assertEquals(a1.equals(c), false); }
/** * Gets the expiry date-time. * <p> * The option expires at this date and time. * <p> * The result is returned by combining the expiry date, time and time-zone. * * @return the expiry date and time */ public ZonedDateTime getExpiry() { return expiryDate.getUnadjusted().atTime(expiryTime).atZone(expiryZone); }
.orElse(BusinessDayAdjustment.NONE); PeriodicSchedule.Builder scheduleBuilder = PeriodicSchedule.builder() .startDate(effectiveDate.getUnadjusted()) .startDateBusinessDayAdjustment(effectiveDate.getAdjustment()) .endDate(terminationDate.getUnadjusted()) .endDateBusinessDayAdjustment(terminationDate.getAdjustment()) .businessDayAdjustment(bda); LocalDate date = initialPaymentEl.findChild("adjustablePaymentDate") .map(el -> document.parseDate(el)) .orElse(effectiveDate.getUnadjusted()); AdjustableDate adjDate = AdjustableDate.of(date, bda); upfrontFee = payRec.isPay() ? AdjustablePayment.ofPay(amount, adjDate) : AdjustablePayment.ofReceive(amount, adjDate); .ifPresent(el -> scheduleBuilder.firstRegularStartDate(document.parseDate(el))); periodicPaymentEl.findChild("firstPeriodStartDate") .ifPresent(el -> scheduleBuilder.overrideStartDate(AdjustableDate.of(document.parseDate(el)))); periodicPaymentEl.findChild("lastRegularPaymentDate") .ifPresent(el -> scheduleBuilder.lastRegularEndDate(document.parseDate(el)));
/** * Resolves the date on this payment, returning a payment with a fixed date. * <p> * This returns a {@link Payment} with the same amount and resolved date. * * @param refData the reference data, used to find the holiday calendar * @return the resolved payment */ @Override public Payment resolve(ReferenceData refData) { return Payment.of(value, date.adjusted(refData)); }
baseDate = parseDate(relativeToEl); } else if (relativeToEl.getName().contains("relative")) { baseDate = parseAdjustedRelativeDateOffset(relativeToEl).getUnadjusted(); } else { throw new FpmlParseException( resolvedDate = bda1.adjust(datePlusBusDays, refData); return AdjustableDate.of(resolvedDate, bda2);
@Override public String formatForCsv(AdjustableDate amount) { return amount.getUnadjusted().toString(); }
.map(el -> document.parseAdjustableDate(el)) .orElseGet(() -> document.parseAdjustedRelativeDateOffset(calcPeriodDatesEl.getChild("relativeEffectiveDate"))); accrualScheduleBuilder.startDate(startDate.getUnadjusted()); if (!bda.equals(startDate.getAdjustment())) { accrualScheduleBuilder.startDateBusinessDayAdjustment(startDate.getAdjustment()); .map(el -> document.parseAdjustableDate(el)) .orElseGet(() -> document.parseAdjustedRelativeDateOffset(calcPeriodDatesEl.getChild("relativeTerminationDate"))); accrualScheduleBuilder.endDate(endDate.getUnadjusted()); if (!bda.equals(endDate.getAdjustment())) { accrualScheduleBuilder.endDateBusinessDayAdjustment(endDate.getAdjustment());
private List<LocalDate> applyBusinessDayAdjustment(List<LocalDate> unadj, ReferenceData refData) { List<LocalDate> adj = new ArrayList<>(unadj.size()); adj.add(calculatedStartDate().adjusted(refData)); for (int i = 1; i < unadj.size() - 1; i++) { adj.add(businessDayAdjustment.adjust(unadj.get(i), refData)); } adj.add(calculatedEndDate().adjusted(refData)); return adj; }
/** * Calculates the applicable end date. * <p> * The result combines the end date and the appropriate business day adjustment. * * @return the calculated end date */ public AdjustableDate calculatedEndDate() { return AdjustableDate.of(endDate, calculatedEndDateBusinessDayAdjustment()); }
public void test_of_2args_withAdjustment() { AdjustableDate test = AdjustableDate.of(FRI_2014_07_11, BDA_FOLLOW_SAT_SUN); assertEquals(test.getUnadjusted(), FRI_2014_07_11); assertEquals(test.getAdjustment(), BDA_FOLLOW_SAT_SUN); assertEquals(test.toString(), "2014-07-11 adjusted by Following using calendar Sat/Sun"); assertEquals(test.adjusted(REF_DATA), FRI_2014_07_11); }
@Override public String formatForDisplay(AdjustableDate amount) { return amount.getUnadjusted().toString(); }
private void assertFra(List<Trade> trades, boolean interpolatedParty1) { assertEquals(trades.size(), 1); Trade trade = trades.get(0); assertEquals(trade.getClass(), FraTrade.class); FraTrade fraTrade = (FraTrade) trade; assertEquals(fraTrade.getInfo().getTradeDate(), Optional.of(date(1991, 5, 14))); StandardId party1id = StandardId.of("http://www.hsbc.com/swaps/trade-id", "MB87623"); StandardId party2id = StandardId.of("http://www.abnamro.com/swaps/trade-id", "AA9876"); assertEquals(fraTrade.getInfo().getId(), Optional.of(interpolatedParty1 ? party1id : party2id)); Fra fra = fraTrade.getProduct(); assertEquals(fra.getBuySell(), interpolatedParty1 ? BUY : SELL); assertEquals(fra.getStartDate(), date(1991, 7, 17)); assertEquals(fra.getEndDate(), date(1992, 1, 17)); assertEquals(fra.getBusinessDayAdjustment(), Optional.empty()); assertEquals(fra.getPaymentDate().getUnadjusted(), date(1991, 7, 17)); assertEquals(fra.getPaymentDate().getAdjustment(), BusinessDayAdjustment.of(FOLLOWING, CHZU)); assertEquals(fra.getFixingDateOffset().getDays(), -2); assertEquals(fra.getFixingDateOffset().getCalendar(), GBLO); assertEquals(fra.getFixingDateOffset().getAdjustment(), BusinessDayAdjustment.NONE); assertEquals(fra.getDayCount(), ACT_360); assertEquals(fra.getCurrency(), CHF); assertEquals(fra.getNotional(), 25000000d); assertEquals(fra.getFixedRate(), 0.04d); assertEquals(fra.getIndex(), interpolatedParty1 ? CHF_LIBOR_3M : CHF_LIBOR_6M); assertEquals(fra.getIndexInterpolated(), interpolatedParty1 ? Optional.of(CHF_LIBOR_6M) : Optional.empty()); assertEquals(fra.getDiscounting(), FraDiscountingMethod.ISDA); }
@Override public ResolvedBulletPayment resolve(ReferenceData refData) { CurrencyAmount signed = payReceive == PayReceive.PAY ? value.negated() : value; Payment payment = Payment.of(signed, date.adjusted(refData)); return ResolvedBulletPayment.of(payment); }
/** * Obtains an instance with no business day adjustment. * <p> * This creates an adjustable date from the specified date. * No business day adjustment applies, thus the result of {@link #adjusted(ReferenceData)} * is the specified date. * * @param date the date * @return the adjustable date */ public static AdjustableDate of(LocalDate date) { return new AdjustableDate(date, BusinessDayAdjustment.NONE); }
@Override public AdjustableDate getStartDate() { return AdjustableDate.of(paymentPeriods.get(0).getStartDate()); }