当前位置: 首页>>代码示例>>Java>>正文


Java ZonedDateTime.with方法代码示例

本文整理汇总了Java中org.threeten.bp.ZonedDateTime.with方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.with方法的具体用法?Java ZonedDateTime.with怎么用?Java ZonedDateTime.with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.threeten.bp.ZonedDateTime的用法示例。


在下文中一共展示了ZonedDateTime.with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextTuesdayMorningTimestamp

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public static long getNextTuesdayMorningTimestamp(boolean allowSameDay) {
    ZonedDateTime nextTuesday;

    if (allowSameDay) {
        // If today is Tuesday (before 08:10), we'll get a timestamp in the future. Great !
        // If today is Tuesday (after 08:10), we'll get a timestamp in the past, AlarmManager is garanteed to trigger immediatly. Neat.
        // If today is not Tuesday, everything is fine, we get next tuesday epoch
        nextTuesday = getNowTime().with(TemporalAdjusters.nextOrSame(DayOfWeek.TUESDAY));
    } else {
        // We are tuesday, get next week timestamp with TemporalAdjusters.next instead of TemporalAdjusters.nextOrSame
        // If we are not tuesday, it doesn't "loop over" and give a timestamp in > 7 days
        nextTuesday = getNowTime().with(TemporalAdjusters.next(DayOfWeek.TUESDAY));
    }

    nextTuesday = nextTuesday.with(LocalTime.of(8, 10)); // TODO VOLKO USER CAN SET THIS IN OPTION

    return nextTuesday.toInstant().toEpochMilli();
}
 
开发者ID:NinoDLC,项目名称:CineReminDay,代码行数:19,代码来源:CRDTimeManager.java

示例2: compile

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
  final ZonedDateTime atZDT = ZonedDateTime.ofInstant(atInstant, ZoneOffset.UTC);
  //TODO work out a way to use dependency graph to get curve information for this config
  final CurveConstructionConfiguration curveConstructionConfiguration = _curveConstructionConfigurationSource.getCurveConstructionConfiguration(_configurationName);
  if (curveConstructionConfiguration == null) {
    throw new OpenGammaRuntimeException("Could not get curve construction configuration called " + _configurationName);
  }
  final ConventionSource conventionSource = OpenGammaCompilationContext.getConventionSource(context);
  final SecuritySource securitySource = OpenGammaCompilationContext.getSecuritySource(context);
  final ConfigSource configSource = OpenGammaCompilationContext.getConfigSource(context);
  try {
    final CurveNodeVisitor<Set<Currency>> visitor = new CurveNodeCurrencyVisitor(conventionSource, securitySource, configSource);
    final Set<Currency> currencies = CurveUtils.getCurrencies(curveConstructionConfiguration, _curveDefinitionSource, _curveConstructionConfigurationSource, visitor);
    final ValueProperties properties = createValueProperties().with(CURVE_CONSTRUCTION_CONFIG, _configurationName).get();
    final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.FX_MATRIX, ComputationTargetSpecification.NULL, properties);
    return new MyCompiledFunction(atZDT.with(LocalTime.MIDNIGHT), atZDT.plusDays(1).with(LocalTime.MIDNIGHT).minusNanos(1000000), spec, currencies);
  } catch (final Throwable e) {
    s_logger.error("{}: problem in CurveConstructionConfiguration called {}", e.getMessage(), _configurationName);
    s_logger.error("Full stack trace", e);
    throw new OpenGammaRuntimeException(e.getMessage() + ": problem in CurveConstructionConfiguration called " + _configurationName);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:FXMatrixFunction.java

示例3: getSchedule

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
  ArgumentChecker.notNull(startDate, "start date");
  ArgumentChecker.notNull(endDate, "end date");
  ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
  if (startDate.equals(endDate)) {
    if (startDate.getDayOfMonth() == 1 && startDate.getMonth() == Month.JANUARY) {
      return new ZonedDateTime[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but neither was the first day of the year");
  }
  final List<ZonedDateTime> dates = new ArrayList<>();
  ZonedDateTime date = startDate.with(TemporalAdjusters.firstDayOfYear());
  if (date.isBefore(startDate)) {
    date = date.plusYears(1);
  }
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plusYears(1);
  }
  return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:FirstOfYearScheduleCalculator.java

示例4: from

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Builder from all the cap/floor details, using details inside the price index with standard reference end date.
 * @param accrualStartDate Start date of the accrual period.
 * @param paymentDate Coupon payment date.
 * @param notional Coupon notional.
 * @param priceIndex The price index associated to the coupon.
 * @param conventionalMonthLag The lag in month between the index validity and the coupon dates.
 * @param monthLag  The lag in month between the index validity and the coupon dates.
 * @param maturity The cap/floor maturity in years.
 * @param lastKnownFixingDate The fixing date (always the first of a month) of the last known fixing.
 * @param strike The strike
 * @param isCap The cap/floor flag.
 * @return The cap/floor.
 */
public static CapFloorInflationZeroCouponInterpolationDefinition from(final ZonedDateTime accrualStartDate, final ZonedDateTime paymentDate, final double notional,
    final IndexPrice priceIndex, final int conventionalMonthLag, final int monthLag, final int maturity, final ZonedDateTime lastKnownFixingDate, final double strike,
    final boolean isCap) {
  Validate.notNull(priceIndex, "Price index");
  final double weight = 1.0 - (paymentDate.getDayOfMonth() - 1.0) / paymentDate.toLocalDate().lengthOfMonth();

  final ZonedDateTime refInterpolatedStartDate = accrualStartDate.minusMonths(monthLag);
  final ZonedDateTime[] referenceStartDates = new ZonedDateTime[2];
  referenceStartDates[0] = refInterpolatedStartDate.with(TemporalAdjusters.lastDayOfMonth());
  referenceStartDates[1] = referenceStartDates[0].plusMonths(1).with(TemporalAdjusters.lastDayOfMonth());

  final ZonedDateTime refInterpolatedEndDate = paymentDate.minusMonths(monthLag);
  final ZonedDateTime[] referenceEndDate = new ZonedDateTime[2];
  referenceEndDate[0] = refInterpolatedEndDate.with(TemporalAdjusters.lastDayOfMonth());
  referenceEndDate[1] = referenceEndDate[0].plusMonths(1).with(TemporalAdjusters.lastDayOfMonth());

  return new CapFloorInflationZeroCouponInterpolationDefinition(priceIndex.getCurrency(), paymentDate, accrualStartDate, paymentDate, 1.0,
      notional, priceIndex, lastKnownFixingDate, conventionalMonthLag, monthLag, maturity, referenceStartDates, referenceEndDate, weight, strike, isCap);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:34,代码来源:CapFloorInflationZeroCouponInterpolationDefinition.java

示例5: getSchedule

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
  ArgumentChecker.notNull(startDate, "start date");
  ArgumentChecker.notNull(endDate, "end date");
  ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
  if (startDate.equals(endDate)) {
    if (startDate.getDayOfMonth() == startDate.toLocalDate().lengthOfMonth()) {
      return new ZonedDateTime[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but neither was the last day of the month");
  }
  final List<ZonedDateTime> dates = new ArrayList<>();
  ZonedDateTime date = startDate.with(TemporalAdjusters.lastDayOfMonth());
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plus(Period.ofMonths(1)).with(TemporalAdjusters.lastDayOfMonth());
  }
  return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:EndOfMonthScheduleCalculator.java

示例6: getSchedule

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
  ArgumentChecker.notNull(startDate, "start date");
  ArgumentChecker.notNull(endDate, "end date");
  ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
  if (startDate.equals(endDate)) {
    if (startDate.getDayOfMonth() == 1) {
      return new ZonedDateTime[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but neither was the first day of the month");
  }
  final List<ZonedDateTime> dates = new ArrayList<>();
  ZonedDateTime date = startDate.with(TemporalAdjusters.firstDayOfMonth());
  if (date.isBefore(startDate)) {
    date = date.plusMonths(1);
  }
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plusMonths(1);
  }
  return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:FirstOfMonthScheduleCalculator.java

示例7: getSchedule

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
  ArgumentChecker.notNull(startDate, "start date");
  ArgumentChecker.notNull(endDate, "end date");
  ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
  if (startDate.equals(endDate)) {
    if (startDate.getDayOfMonth() == 31 && startDate.getMonth() == Month.DECEMBER) {
      return new ZonedDateTime[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but neither was the last day of the year");
  }
  final List<ZonedDateTime> dates = new ArrayList<>();
  ZonedDateTime date = startDate.with(TemporalAdjusters.lastDayOfYear());
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plusYears(1).with(TemporalAdjusters.lastDayOfYear());
  }
  return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:EndOfYearScheduleCalculator.java

示例8: getSchedule

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
  ArgumentChecker.notNull(startDate, "start date");
  ArgumentChecker.notNull(endDate, "end date");
  ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
  if (startDate.equals(endDate)) {
    if (startDate.getDayOfWeek() == _dayOfWeek) {
      return new ZonedDateTime[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but their day of week was not the same as that required");
  }
  final List<ZonedDateTime> dates = new ArrayList<>();
  ZonedDateTime date = startDate;
  date = date.with(TemporalAdjusters.nextOrSame(_dayOfWeek));
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.with(TemporalAdjusters.next(_dayOfWeek));
  }
  return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:WeeklyScheduleOnDayCalculator.java

示例9: getSchedule

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
  Validate.notNull(startDate, "start date");
  Validate.notNull(endDate, "end date");
  Validate.isTrue(startDate.isBefore(endDate) || startDate.equals(endDate));
  if (startDate.equals(endDate)) {
    if (MonthDay.from(startDate).equals(_monthDay)) {
      return new ZonedDateTime[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but the day of month and month of year were not those required");
  }
  ZonedDateTime date = startDate.with(_monthDay);
  if (date.isBefore(startDate)) {
    date = date.plusYears(1);
  }
  final List<ZonedDateTime> dates = new ArrayList<>();
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plusYears(1);
  }
  return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:AnnualScheduleOnDayAndMonthCalculator.java

示例10: compile

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
  final ZonedDateTime atZDT = ZonedDateTime.ofInstant(atInstant, ZoneOffset.UTC);
  try {
    final AbstractCurveSpecification curveSpecification = CurveUtils.getSpecification(atInstant, _curveDefinitionSource, _curveSpecificationBuilder, atZDT.toLocalDate(), _curveName);
    final ValueProperties properties = createValueProperties().with(ValuePropertyNames.CURVE, _curveName).get();
    final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.CURVE_SPECIFICATION, ComputationTargetSpecification.NULL, properties);
    return new MyCompiledFunction(atZDT.with(LocalTime.MIDNIGHT), atZDT.plusDays(1).with(LocalTime.MIDNIGHT).minusNanos(1000000), curveSpecification, spec);
  } catch (final Exception e) {
    throw new OpenGammaRuntimeException(e.getMessage() + ": problem in CurveSpecification called " + _curveName);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:13,代码来源:CurveSpecificationFunction.java

示例11: compile

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
  final ZonedDateTime atZDT = ZonedDateTime.ofInstant(atInstant, ZoneOffset.UTC);
  final ValueProperties properties = createValueProperties().with(ValuePropertyNames.CURVE, _curveName).get();
  final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.CURVE_MARKET_DATA, ComputationTargetSpecification.NULL, properties);
  try {
    final AbstractCurveSpecification specification = CurveUtils.getSpecification(atInstant, _curveDefinitionSource, _curveSpecificationBuilder, atZDT.toLocalDate(), _curveName);
    return new MyCompiledFunction(atZDT.with(LocalTime.MIDNIGHT), atZDT.plusDays(1).with(LocalTime.MIDNIGHT).minusNanos(1000000), specification, spec);
  } catch (final Exception e) {
    throw new OpenGammaRuntimeException(e.getMessage() + ": problem in CurveDefinition called " + _curveName);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:13,代码来源:CurveMarketDataFunction.java

示例12: toDerivative

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Payment toDerivative(final ZonedDateTime date, final DoubleTimeSeries<ZonedDateTime> indexFixingTimeSeries) {
  ArgumentChecker.notNull(date, "date");
  ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
  final ZonedDateTime zonedDate = date.toLocalDate().atStartOfDay(ZoneOffset.UTC);
  double paymentTime = TimeCalculator.getTimeBetween(zonedDate, getPaymentDate()); // Calendar????
  if (date.isAfter(getFixingDate()) || (date.equals(getFixingDate()))) {
    Double fixedRate = indexFixingTimeSeries.getValue(getFixingDate());
    //TODO remove me when times are sorted out in the swap definitions or we work out how to deal with this another way
    if (fixedRate == null) {
      final ZonedDateTime fixingDateAtLiborFixingTime = getFixingDate().with(LocalTime.of(11, 0));
      fixedRate = indexFixingTimeSeries.getValue(fixingDateAtLiborFixingTime);
    }
    if (fixedRate == null) {
      final ZonedDateTime previousBusinessDay = PRECEDING_BDC.adjustDate(_calendar,
          getFixingDate().minusDays(1));
      fixedRate = indexFixingTimeSeries.getValue(previousBusinessDay);
      //TODO remove me when times are sorted out in the swap definitions or we work out how to deal with this another way
      if (fixedRate == null) {
        final ZonedDateTime previousBusinessDayAtLiborFixingTime = previousBusinessDay.with(LocalTime.of(11, 0));
        fixedRate = indexFixingTimeSeries.getValue(previousBusinessDayAtLiborFixingTime);
      }
      if (fixedRate == null) {
        throw new OpenGammaRuntimeException("Could not get fixing value for date " + getFixingDate());
      }
    }
    return new CouponFixed(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), fixedRate - _rate);
  }

  // Ibor is not fixed yet, all the details are required.
  double fixingTime = TimeCalculator.getTimeBetween(zonedDate, getFixingDate());
  double fixingPeriodStartTime = TimeCalculator.getTimeBetween(zonedDate, getFixingPeriodStartDate());
  double fixingPeriodEndTime = TimeCalculator.getTimeBetween(zonedDate, getFixingPeriodEndDate());
  return new ForwardRateAgreement(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), _index, fixingTime, fixingPeriodStartTime,
      fixingPeriodEndTime, getFixingPeriodAccrualFactor(), _rate);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:37,代码来源:ForwardRateAgreementDefinition.java

示例13: toDerivative

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Coupon toDerivative(final ZonedDateTime date, final DoubleTimeSeries<ZonedDateTime> indexFixingTS) {
  ArgumentChecker.notNull(date, "date");
  ArgumentChecker.notNull(indexFixingTS, "index fixing time series");
  ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date " + date + " " + getPaymentDate());
  final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
  if (date.isAfter(getFixingDate()) || date.equals(getFixingDate())) { // The Ibor cap/floor has already fixed, it is now a fixed coupon.
    Double fixedRate = indexFixingTS.getValue(getFixingDate());
    //TODO remove me when times are sorted out in the swap definitions or we work out how to deal with this another way
    if (fixedRate == null) {
      final ZonedDateTime fixingDateAtLiborFixingTime = getFixingDate().with(LocalTime.of(11, 0));
      fixedRate = indexFixingTS.getValue(fixingDateAtLiborFixingTime);
    }
    if (fixedRate == null) {
      final ZonedDateTime previousBusinessDay = BusinessDayConventions.PRECEDING.adjustDate(_calendar, getFixingDate().minusDays(1));
      fixedRate = indexFixingTS.getValue(previousBusinessDay);
      //TODO remove me when times are sorted out in the swap definitions or we work out how to deal with this another way
      if (fixedRate == null) {
        final ZonedDateTime previousBusinessDayAtLiborFixingTime = previousBusinessDay.with(LocalTime.of(11, 0));
        fixedRate = indexFixingTS.getValue(previousBusinessDayAtLiborFixingTime);
      }
      if (fixedRate == null) {
        fixedRate = indexFixingTS.getLatestValue(); //TODO remove me as soon as possible
      }
    }
    return new CouponFixed(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), payOff(fixedRate));
  }
  // Ibor is not fixed yet, all the details are required.
  final double fixingTime = TimeCalculator.getTimeBetween(date, getFixingDate());
  final double fixingPeriodStartTime = TimeCalculator.getTimeBetween(date, getFixingPeriodStartDate());
  final double fixingPeriodEndTime = TimeCalculator.getTimeBetween(date, getFixingPeriodEndDate());
  //TODO: Definition has no spread and time version has one: to be standardized.
  return new CapFloorIbor(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), fixingTime, getIndex(), fixingPeriodStartTime, fixingPeriodEndTime,
      getFixingPeriodAccrualFactor(), _strike, _isCap);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:36,代码来源:CapFloorIborDefinition.java

示例14: toDerivative

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Coupon toDerivative(final ZonedDateTime date, final DoubleTimeSeries<ZonedDateTime> data) {
  ArgumentChecker.notNull(date, "date");
  ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
  // First curve used for discounting. If two curves, the same forward is used for both swaps;
  // if more than two curves, the second is used for the forward of the first swap and the third for the forward of the second swap.
  final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
  if (date.isAfter(getFixingDate()) || date.equals(getFixingDate())) { // The CMS coupon has already fixed, it is now a fixed coupon.
    Double fixedRate = data.getValue(getFixingDate());
    //TODO remove me when times are sorted out in the swap definitions or we work out how to deal with this another way
    if (fixedRate == null) {
      final ZonedDateTime fixingDateAtLiborFixingTime = getFixingDate().with(LocalTime.of(11, 0));
      fixedRate = data.getValue(fixingDateAtLiborFixingTime);
    }
    if (fixedRate == null) {
      final ZonedDateTime previousBusinessDay = BusinessDayConventions.PRECEDING.adjustDate(_calendar1,
          getFixingDate().minusDays(1));
      fixedRate = data.getValue(previousBusinessDay);
      //TODO remove me when times are sorted out in the swap definitions or we work out how to deal with this another way
      if (fixedRate == null) {
        final ZonedDateTime previousBusinessDayAtLiborFixingTime = previousBusinessDay.with(LocalTime.of(11, 0));
        fixedRate = data.getValue(previousBusinessDayAtLiborFixingTime);
      }
      if (fixedRate == null) {
        fixedRate = data.getLatestValue(); //TODO remove me as soon as possible
        //throw new OpenGammaRuntimeException("Could not get fixing value for date " + getFixingDate());
      }
    }

    return new CouponFixed(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), payOff(fixedRate));
  }
  // CMS spread is not fixed yet, all the details are required.
  final double fixingTime = TimeCalculator.getTimeBetween(date, getFixingDate());
  final double settlementTime = TimeCalculator.getTimeBetween(date, _underlyingSwap1.getFixedLeg().getNthPayment(0).getAccrualStartDate());
  final SwapFixedCoupon<Coupon> swap1 = _underlyingSwap1.toDerivative(date);
  final SwapFixedCoupon<Coupon> swap2 = _underlyingSwap2.toDerivative(date);
  return new CapFloorCMSSpread(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), fixingTime, swap1, _cmsIndex1, swap2, _cmsIndex2, settlementTime, _strike, _isCap);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:39,代码来源:CapFloorCMSSpreadDefinition.java

示例15: from

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Builder for inflation zero-coupon based on an inflation lag and the index publication lag. The fixing date is the publication lag after the last reference month.
 * @param accrualStartDate Start date of the accrual period.
 * @param paymentDate The payment date.
 * @param notional Coupon notional.
 * @param priceIndex The price index associated to the coupon.
 * @param indexStartValue The index value at the start of the coupon.
 * @param conventionalMonthLag The lag in month between the index validity and the coupon dates for the standard product.
 * @param monthLag The lag in month between the index validity and the coupon dates for the actual product.
 * @param payNotional Flag indicating if the notional is paid (true) or not (false).
 * @param factor The multiplicative factor.
 * @return The inflation zero-coupon.
 */
public static CouponInflationZeroCouponInterpolationGearingDefinition from(final ZonedDateTime accrualStartDate, final ZonedDateTime paymentDate,
    final double notional, final IndexPrice priceIndex, final double indexStartValue, final int conventionalMonthLag, final int monthLag, final boolean payNotional, final double factor) {
  final ZonedDateTime refInterpolatedStartDate = accrualStartDate.minusMonths(monthLag);
  final ZonedDateTime[] referenceStartDates = new ZonedDateTime[2];
  referenceStartDates[0] = refInterpolatedStartDate.with(TemporalAdjusters.lastDayOfMonth());
  referenceStartDates[1] = referenceStartDates[0].plusMonths(1).with(TemporalAdjusters.lastDayOfMonth());

  final ZonedDateTime refInterpolatedEndDate = paymentDate.minusMonths(monthLag);
  final ZonedDateTime[] referenceEndDates = new ZonedDateTime[2];
  referenceEndDates[0] = refInterpolatedEndDate.with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0);
  referenceEndDates[1] = referenceEndDates[0].plusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0);
  return from(priceIndex.getCurrency(), paymentDate, accrualStartDate, paymentDate, 1.0, notional, priceIndex,
      conventionalMonthLag, monthLag, referenceStartDates, indexStartValue, referenceEndDates, payNotional, factor);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:28,代码来源:CouponInflationZeroCouponInterpolationGearingDefinition.java


注:本文中的org.threeten.bp.ZonedDateTime.with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。