@Override public LocalDate getPaymentDate() { return payment.getDate(); }
/** * Returns the date that the transaction settles. * <p> * This returns the settlement date of the base currency. * * @return the value date */ public LocalDate getPaymentDate() { return baseCurrencyPayment.getDate(); }
@Override public LocalDate getPaymentDate() { return payment.getDate(); }
@Override public LocalDate getPaymentDate() { return payment.getDate(); }
/** * Gets the last payment date. * <p> * The payment date is normally the same for the base and counter currencies. * If it differs, this method returns the latest of the two dates. * * @return the latest payment date */ public LocalDate getPaymentDate() { return Ordering.natural().max(baseCurrencyPayment.getDate(), counterCurrencyPayment.getDate()); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(Payment beanToCopy) { this.value = beanToCopy.getValue(); this.date = beanToCopy.getDate(); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 111972721: // value return ((Payment) bean).getValue(); case 3076014: // date return ((Payment) bean).getDate(); } return super.propertyGet(bean, propertyName, quiet); }
/** * Computes the yield from the price at a given settlement date. * * @param price the price * @param settlementDate the settlement date * @return the yield */ public double yieldFromPrice(double price, LocalDate settlementDate) { double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate()); return yieldConvention.yieldFromPrice(price, accrualFactor); }
/** * Obtains an instance based on a {@code Payment}. * * @param payment the fixed payment * @return the adjustable payment instance */ public static AdjustablePayment of(Payment payment) { return of(payment.getValue(), payment.getDate()); }
/** * Computes the price from the yield at a given settlement date. * * @param yield the yield * @param settlementDate the settlement date * @return the price */ public double priceFromYield(double yield, LocalDate settlementDate) { double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate()); return yieldConvention.priceFromYield(yield, accrualFactor); }
@ImmutableValidator private void validate() { if (baseCurrencyPayment.getCurrency().equals(counterCurrencyPayment.getCurrency())) { throw new IllegalArgumentException("Payments must have different currencies"); } if ((baseCurrencyPayment.getAmount() != 0d || counterCurrencyPayment.getAmount() != 0d) && Math.signum(baseCurrencyPayment.getAmount()) != -Math.signum(counterCurrencyPayment.getAmount())) { throw new IllegalArgumentException("Payments must have different signs"); } ArgChecker.inOrderOrEqual(baseCurrencyPayment.getDate(), counterCurrencyPayment.getDate(), "baseCurrencyPayment.date", "counterCurrencyPayment.date"); }
@Override public NotionalExchange adjustPaymentDate(TemporalAdjuster adjuster) { LocalDate adjusted = payment.getDate().with(adjuster); return of(payment.getValue(), adjusted); }
public void test_upfrontPayment() { Payment payment = TRADE_PRICER.upfrontPayment(TRADE); assertEquals(payment.getCurrency(), EUR); assertEquals(payment.getAmount(), -NOTIONAL * QUANTITY * DIRTY_PRICE, TOL); assertEquals(payment.getDate(), SETTLEMENT); }
/** * Calculates the current cash. * * @param payment the payment * @param provider the provider * @return the current cash */ public CurrencyAmount currentCash(Payment payment, BaseProvider provider) { if (payment.getDate().isEqual(provider.getValuationDate())) { return payment.getValue(); } return CurrencyAmount.zero(payment.getCurrency()); }
public void test_explainPresentValue_provider_ended() { ExplainMap explain = PRICER.explainPresentValue(PAYMENT_PAST, PROVIDER); Currency currency = PAYMENT_PAST.getCurrency(); assertEquals(explain.get(ExplainKey.ENTRY_TYPE).get(), "Payment"); assertEquals(explain.get(ExplainKey.PAYMENT_DATE).get(), PAYMENT_PAST.getDate()); assertEquals(explain.get(ExplainKey.PAYMENT_CURRENCY).get(), currency); assertEquals(explain.get(ExplainKey.FORECAST_VALUE).get().getCurrency(), currency); assertEquals(explain.get(ExplainKey.FORECAST_VALUE).get().getAmount(), 0, TOL); assertEquals(explain.get(ExplainKey.PRESENT_VALUE).get().getCurrency(), currency); assertEquals(explain.get(ExplainKey.PRESENT_VALUE).get().getAmount(), 0, TOL); }
public void test_upfrontPayment_position() { Payment payment = TRADE_PRICER.upfrontPayment(POSITION); assertEquals(payment.getCurrency(), EUR); assertEquals(payment.getAmount(), 0, TOL); assertEquals(payment.getDate(), POSITION.getProduct().getStartDate()); }
public void price_from_yield_discount() { ResolvedBill bill = sut(); double yield = 0.01; LocalDate settlementDate = LocalDate.of(2018, 8, 17); double af = bill.getDayCount().relativeYearFraction(settlementDate, bill.getNotional().getDate()); double priceExpected = 1.0d - yield * af; double priceComputed = bill.priceFromYield(yield, settlementDate); assertEquals(priceExpected, priceComputed, TOLERANCE_PRICE); }
public void yield_from_price_discount() { ResolvedBill bill = sut(); double price = 0.99; LocalDate settlementDate = LocalDate.of(2018, 8, 17); double af = bill.getDayCount().relativeYearFraction(settlementDate, bill.getNotional().getDate()); double yieldExpected = (1.0d - price) / af; double yieldComputed = bill.yieldFromPrice(price, settlementDate); assertEquals(yieldExpected, yieldComputed, TOLERANCE_PRICE); }
public void yield_from_price_intatmat() { ResolvedBill bill = BillTest.US_BILL .toBuilder().yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build().resolve(REF_DATA); double price = 0.99; LocalDate settlementDate = LocalDate.of(2018, 8, 17); double af = bill.getDayCount().relativeYearFraction(settlementDate, bill.getNotional().getDate()); double yieldExpected = (1.0d / price - 1.0d) / af; double yieldComputed = bill.yieldFromPrice(price, settlementDate); assertEquals(yieldExpected, yieldComputed, TOLERANCE_PRICE); }
public void price_from_yield_intatmat() { ResolvedBill bill = BillTest.US_BILL .toBuilder().yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build().resolve(REF_DATA); double yield = 0.01; LocalDate settlementDate = LocalDate.of(2018, 8, 17); double af = bill.getDayCount().relativeYearFraction(settlementDate, bill.getNotional().getDate()); double priceExpected = 1.0d / (1 + yield * af); double priceComputed = bill.priceFromYield(yield, settlementDate); assertEquals(priceExpected, priceComputed, TOLERANCE_PRICE); }