Package org.threeten.bp

Examples of org.threeten.bp.Period


  @Test
  /**
   * Tests the present value of an annuity vs the sum of pv of each caplet.
   */
  public void presentValueAnnuity() {
    final Period START_CMSCAP = Period.ofYears(5);
    final Period LENGTH_CMSCAP = Period.ofYears(10);
    final ZonedDateTime START_DATE = ScheduleCalculator.getAdjustedDate(SPOT_DATE, START_CMSCAP, EUR1YEURIBOR6M.getIborIndex().getBusinessDayConvention(), CALENDAR, EUR1YEURIBOR6M.getIborIndex()
        .isEndOfMonth());
    final ZonedDateTime END_DATE = START_DATE.plus(LENGTH_CMSCAP);
    final Period capPeriod = Period.ofMonths(6);
    final DayCount capDayCount = DayCountFactory.INSTANCE.getDayCount("ACT/360");
    final AnnuityCapFloorCMSDefinition capDefinition = AnnuityCapFloorCMSDefinition.from(START_DATE, END_DATE, NOTIONAL, INDEX_SWAP_5Y, capPeriod, capDayCount, false, STRIKE, IS_CAP, CALENDAR);
    final Annuity<? extends Payment> cap = capDefinition.toDerivative(REFERENCE_DATE);
    final double pvCalculator = PVSSC.visit(cap, SABR_MULTICURVES).getAmount(EUR);
    double pvExpected = 0.0;
View Full Code Here


  @Test
  /**
   * Tests the present value of an annuity vs the sum of pv of each caplet.
   */
  public void presentValueCurveSensitivityAnnuity() {
    final Period START_CMSCAP = Period.ofYears(5);
    final Period LENGTH_CMSCAP = Period.ofYears(10);
    final ZonedDateTime START_DATE = ScheduleCalculator.getAdjustedDate(SPOT_DATE, START_CMSCAP, EUR1YEURIBOR6M.getIborIndex().getBusinessDayConvention(), CALENDAR, EUR1YEURIBOR6M.getIborIndex()
        .isEndOfMonth());
    final ZonedDateTime END_DATE = START_DATE.plus(LENGTH_CMSCAP);
    final Period capPeriod = Period.ofMonths(6);
    final DayCount capDayCount = DayCountFactory.INSTANCE.getDayCount("ACT/360");
    final AnnuityCapFloorCMSDefinition capDefinition = AnnuityCapFloorCMSDefinition.from(START_DATE, END_DATE, NOTIONAL, INDEX_SWAP_5Y, capPeriod, capDayCount, false, STRIKE, IS_CAP, CALENDAR);
    final Annuity<? extends Payment> cap = capDefinition.toDerivative(REFERENCE_DATE);
    MultipleCurrencyMulticurveSensitivity pvcsCalculator = PVCSSSC.visit(cap, SABR_MULTICURVES);
    pvcsCalculator = pvcsCalculator.cleaned();
View Full Code Here

   */
  public void calibration() {
    // creation of the basket of the calibration instruments.
    for (int loop1 = 0; loop1 < STRIKES.length; loop1++) {
      for (int loop2 = 0; loop2 < availabelTenor.length; loop2++) {
        final Period tenor = Period.ofYears(availabelTenor[loop2]);
        final ZonedDateTime payementDate = ScheduleCalculator.getAdjustedDate(START_DATE, tenor, BUSINESS_DAY, CALENDAR_EUR);
        CAP_DEFINITIONS[loop1][loop2] = CapFloorInflationZeroCouponInterpolationDefinition.from(SETTLEMENT_DATE, payementDate, NOTIONAL, PRICE_INDEX_EUR, MONTH_LAG, MONTH_LAG,
            availabelTenor[loop2], LAST_KNOWN_FIXING_DATE, STRIKES[loop1], IS_CAP);
        CAPS[loop1][loop2] = (CapFloorInflationZeroCouponInterpolation) CAP_DEFINITIONS[loop1][loop2].toDerivative(REFERENCE_DATE, priceIndexTS);
      }
View Full Code Here

  @Test(enabled = false)
  public void performance() {
    // creation of the basket of the calibration instruments.
    for (int loop1 = 0; loop1 < STRIKES.length; loop1++) {
      for (int loop2 = 0; loop2 < availabelTenor.length; loop2++) {
        final Period tenor = Period.ofYears(availabelTenor[loop2]);
        final ZonedDateTime payementDate = ScheduleCalculator.getAdjustedDate(START_DATE, tenor, BUSINESS_DAY, CALENDAR_EUR);
        CAP_DEFINITIONS[loop1][loop2] = CapFloorInflationZeroCouponInterpolationDefinition.from(SETTLEMENT_DATE, payementDate, NOTIONAL, PRICE_INDEX_EUR, MONTH_LAG, MONTH_LAG,
            availabelTenor[loop2], LAST_KNOWN_FIXING_DATE, STRIKES[loop1], IS_CAP);
        CAPS[loop1][loop2] = CAP_DEFINITIONS[loop1][loop2].toDerivative(REFERENCE_DATE);
      }
View Full Code Here

  public void performance() {
    long startTime, endTime;
    final int nbTest = 100;

    final ZonedDateTime referenceDate = TRADE_DATE;
    final Period tenor = Period.ofYears(50);
    SwapFixedONDefinition oidUsd5YDefinition;
    Swap<? extends Payment, ? extends Payment> ois;

    final double[] pv = new double[nbTest];
    final InterestRateCurveSensitivity[] pvcs = new InterestRateCurveSensitivity[nbTest];
View Full Code Here

  public String getPrefix() {
    return _prefix;
  }

  private String getTenorString(final Tenor tenor) {
    final Period period = tenor.getPeriod();
    if (period.getYears() != 0) {
      return period.getYears() + "Y";
    } else if (period.getMonths() != 0) {
      return period.getMonths() + "M";
    }
    throw new OpenGammaRuntimeException("Can only handle tenors in units of months or years");
  }
View Full Code Here

    }
    if (convention.getBondSettlementDays(firstAccrualDate, maturityDate) == null) {
      throw new OpenGammaRuntimeException("Could not get bond settlement days from " + conventionName);
    }
    final int settlementDays = convention.getBondSettlementDays(firstAccrualDate, maturityDate);
    final Period paymentPeriod = getTenor(security.getCouponFrequency());
    final ZonedDateTime firstCouponDate = ZonedDateTime.of(security.getFirstCouponDate().toLocalDate().atStartOfDay(), zone);
    return BondFixedSecurityDefinition.from(currency, firstAccrualDate, firstCouponDate, maturityDate, paymentPeriod, rate, settlementDays, calendar, dayCount, businessDay,
        yieldConvention, isEOM, security.getIssuerName());
  }
View Full Code Here

    if (iborIndexConvention == null) {
      throw new OpenGammaRuntimeException("Could not get Ibor index convention for " + currency + " using " + iborLeg.getFloatingReferenceRateId() + " from swap " +
          swapSecurity.getExternalIdBundle());
    }
    final Frequency freqIbor = iborLeg.getFrequency();
    final Period tenorIbor = getTenor(freqIbor);
    final IborIndex indexIbor = new IborIndex(currency, tenorIbor, iborIndexConvention.getSettlementDays(), iborIndexConvention.getDayCount(),
        iborIndexConvention.getBusinessDayConvention(), iborIndexConvention.isEOMConvention(), iborIndexConvention.getName());
    final Frequency freqFixed = fixedLeg.getFrequency();
    final Period tenorFixed = getTenor(freqFixed);
    final double fixedLegNotional = ((InterestRateNotional) fixedLeg.getNotional()).getAmount();
    final double iborLegNotional = ((InterestRateNotional) iborLeg.getNotional()).getAmount();
    if (hasSpread) {
      final double spread = ((FloatingSpreadIRLeg) iborLeg).getSpread();
      return SwapFixedIborSpreadDefinition.from(effectiveDate, maturityDate, tenorFixed, fixedLeg.getDayCount(), fixedLeg.getBusinessDayConvention(), fixedLeg.isEom(), fixedLegNotional,
View Full Code Here

    final String currencyString = currency.getCode();
    final Integer publicationLag = indexConvention.getOvernightIndexSwapPublicationLag();
    if (publicationLag == null) {
      throw new OpenGammaRuntimeException("Could not get ON Index publication lag for " + indexConvention.getIdentifiers());
    }
    final Period paymentFrequency = getTenor(floatLeg.getFrequency());
    final IndexON index = new IndexON(floatLeg.getFloatingReferenceRateId().getValue(), currency, indexConvention.getDayCount(), publicationLag);
    final GeneratorSwapFixedON generator = new GeneratorSwapFixedON(currencyString + "_OIS_Convention", index, paymentFrequency, fixedLeg.getDayCount(), fixedLeg.getBusinessDayConvention(),
        fixedLeg.isEom(), 0, 1 - publicationLag, calendar); // TODO: The payment lag is not available at the security level!
    final double notionalFixed = ((InterestRateNotional) fixedLeg.getNotional()).getAmount();
    final double notionalOIS = ((InterestRateNotional) floatLeg.getNotional()).getAmount();
View Full Code Here

    if (businessDay == null) {
      throw new OpenGammaRuntimeException("Could not get Business Day for " + fixedLeg);
    }
    final boolean isEOM = fixedLeg.isEom();
    final Frequency freqFixed = fixedLeg.getFrequency();
    final Period tenorFixed = getTenor(freqFixed);
    return AnnuityCouponFixedDefinition.from(((InterestRateNotional) fixedLeg.getNotional()).getCurrency(), effectiveDate, maturityDate, tenorFixed, calendar, fixedLeg.getDayCount(), businessDay,
        isEOM, notional, fixedLeg.getRate(), isPayer);
  }
View Full Code Here

TOP

Related Classes of org.threeten.bp.Period

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.