Package org.threeten.bp

Examples of org.threeten.bp.Period


    final String expiryCalculatorName = futureConvention.getExpiryConvention().getValue();
    final IborIndexConvention indexConvention = _conventionSource.getConvention(IborIndexConvention.class, rateFuture.getUnderlyingConvention());
    if (indexConvention == null) {
      throw new OpenGammaRuntimeException("Underlying convention was null");
    }
    final Period indexTenor = rateFuture.getUnderlyingTenor().getPeriod();
    final double paymentAccrualFactor = indexTenor.toTotalMonths() / 12.; //TODO don't use this method
    final Currency currency = indexConvention.getCurrency();
    final Calendar fixingCalendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getFixingCalendar());
    final Calendar regionCalendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getRegionCalendar());
    final BusinessDayConvention businessDayConvention = indexConvention.getBusinessDayConvention();
    final DayCount dayCount = indexConvention.getDayCount();
View Full Code Here


   * @param obsFreq The observation frequency
   * @return The number of expected business days between the start and end dates
   */
  protected static int countExpectedGoodDays(final LocalDate obsStartDate, final LocalDate obsEndDate, final Calendar calendar, final PeriodFrequency obsFreq) {
    int nGood = 0;
    final Period period = obsFreq.getPeriod();
    LocalDate date = obsStartDate;
    while (!date.isAfter(obsEndDate)) {
      if (calendar.isWorkingDay(date)) {
        nGood++;
      }
View Full Code Here

  private Pair<SwaptionSecurity, SwapSecurity> makeSwaptionAndUnderlying(final Random random, final Currency ccy, final LocalDate tradeDate, final Tenor expiry, final Tenor maturity) {
    final ExternalId region = REGIONS.get(ccy);
    final ExternalId floatingRate = IBOR.get(ccy);
    final String swaptionString;
    final Period expiryPeriod = expiry.getPeriod();
    if (expiryPeriod.getYears() != 0) {
      swaptionString = expiryPeriod.getYears() + "Y";
    } else if (expiryPeriod.getMonths() != 0) {
      swaptionString = expiryPeriod.getMonths() + "M";
    } else {
      throw new OpenGammaRuntimeException("Could not handle swaption expiry " + expiry);
    }
    final String swapString;
    final Period maturityPeriod = maturity.getPeriod();
    if (maturityPeriod.getYears() != 0) {
      swapString = maturityPeriod.getYears() + "Y";
    } else if (maturityPeriod.getMonths() != 0) {
      swapString = maturityPeriod.getMonths() + "M";
    } else {
      throw new OpenGammaRuntimeException("Could not handle swap maturity " + maturity);
    }
    final ZonedDateTime swaptionExpiry = tradeDate.plus(expiryPeriod).atStartOfDay().atZone(ZoneOffset.UTC);
    final ZonedDateTime swapMaturity = swaptionExpiry.plus(maturity.getPeriod());
View Full Code Here

    ArgumentChecker.notNull(tradeDate, "trade date");
    ArgumentChecker.notNull(startPeriod, "start period");
    ArgumentChecker.notNull(index, "index");
    final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(tradeDate, index.getSpotLag(), calendar);
    final ZonedDateTime accrualStartDate = ScheduleCalculator.getAdjustedDate(spotDate, startPeriod, index, calendar);
    final Period endPeriod = startPeriod.plus(index.getTenor());
    final ZonedDateTime accrualEndDate = ScheduleCalculator.getAdjustedDate(spotDate, endPeriod, index, calendar);
    final ZonedDateTime fixingDate = ScheduleCalculator.getAdjustedDate(accrualStartDate, -index.getSpotLag(), calendar);
    final double accrualFactor = index.getDayCount().getDayCountFraction(accrualStartDate, accrualEndDate, calendar);
    return new ForwardRateAgreementDefinition(index.getCurrency(), accrualStartDate, accrualStartDate, accrualEndDate, accrualFactor, notional, fixingDate, index, rate,
        calendar);
View Full Code Here

   */
  @Override
  public ForwardRateAgreementDefinition generateInstrument(final ZonedDateTime date, final double rate, final double notional, final GeneratorAttributeIR attribute) {
    ArgumentChecker.notNull(date, "Reference date");
    ArgumentChecker.notNull(attribute, "Attributes");
    final Period startPeriod = attribute.getEndPeriod().minus(_iborIndex.getTenor());
    return ForwardRateAgreementDefinition.fromTrade(date, startPeriod, notional, _iborIndex, rate, _calendar);
  }
View Full Code Here

   * @return The adjusted dates schedule.
   */
  public static ZonedDateTime[] getAdjustedDateSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate, final Frequency scheduleFrequency,
      final boolean stubShort, final boolean fromEnd, final BusinessDayConvention convention, final Calendar calendar, final boolean eomRule) {
    ArgumentChecker.notNull(scheduleFrequency, "Schedule frequency");
    final Period schedulePeriod = periodFromFrequency(scheduleFrequency);
    return getAdjustedDateSchedule(startDate, endDate, schedulePeriod, stubShort, fromEnd, convention, calendar, eomRule);
  }
View Full Code Here

    } else if (frequency instanceof SimpleFrequency) {
      periodFrequency = ((SimpleFrequency) frequency).toPeriodFrequency();
    } else {
      throw new IllegalArgumentException("For the moment can only deal with PeriodFrequency and SimpleFrequency");
    }
    final Period period = periodFrequency.getPeriod();
    final List<ZonedDateTime> dates = new ArrayList<>();
    ZonedDateTime date = effectiveDate; // TODO this is only correct if effective date = accrual date
    date = date.plus(period);
    while (isWithinSwapLifetime(date, maturityDate)) { // REVIEW: could speed this up by working out how many periods between start and end date?
      dates.add(date);
View Full Code Here

    } else if (frequency instanceof SimpleFrequency) {
      periodFrequency = ((SimpleFrequency) frequency).toPeriodFrequency();
    } else {
      throw new IllegalArgumentException("For the moment can only deal with PeriodFrequency and SimpleFrequency");
    }
    final Period period = periodFrequency.getPeriod();
    final List<ZonedDateTime> dates = new ArrayList<>();
    ZonedDateTime date = maturityDate;

    // TODO review the tolerance given
    while (date.isAfter(effectiveDate) && DateUtils.getExactDaysBetween(effectiveDate, date) > 4.0) {
View Full Code Here

    } else if (frequency instanceof SimpleFrequency) {
      periodFrequency = ((SimpleFrequency) frequency).toPeriodFrequency();
    } else {
      throw new IllegalArgumentException("For the moment can only deal with PeriodFrequency and SimpleFrequency");
    }
    final Period period = periodFrequency.getPeriod();
    return getAdjustedDateSchedule(startDate, endDate, period, businessDayConvention, calendar, isEOM, true);
  }
View Full Code Here

    } else if (frequency instanceof SimpleFrequency) {
      periodFrequency = ((SimpleFrequency) frequency).toPeriodFrequency();
    } else {
      throw new IllegalArgumentException("For the moment can only deal with PeriodFrequency and SimpleFrequency");
    }
    final Period period = periodFrequency.getPeriod();

    final int n = dates.length;
    final ZonedDateTime[] results = new ZonedDateTime[n];
    results[0] = effectiveDate.plus(period);
    for (int i = 1; i < n; i++) {
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.