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


Java ZonedDateTime.getDayOfMonth方法代码示例

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


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

示例1: equalsToAccuracy

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Compares two expiry dates for equality to the given level of accuracy only.
 *
 * @param accuracy  the accuracy to compare to, not null
 * @param expiry1  the first date/time to compare, not null
 * @param expiry2  the second date/time to compare, not null
 * @return true if the two dates/times are equal to the requested accuracy
 */
public static boolean equalsToAccuracy(final ExpiryAccuracy accuracy, final ZonedDateTime expiry1, final ZonedDateTime expiry2) {
  switch (accuracy) {
    case MIN_HOUR_DAY_MONTH_YEAR:
      return (expiry1.getMinute() == expiry2.getMinute()) && (expiry1.getHour() == expiry2.getHour()) && (expiry1.getDayOfMonth() == expiry2.getDayOfMonth())
          && (expiry1.getMonth() == expiry2.getMonth()) && (expiry1.getYear() == expiry2.getYear());
    case HOUR_DAY_MONTH_YEAR:
      return (expiry1.getHour() == expiry2.getHour()) && (expiry1.getDayOfMonth() == expiry2.getDayOfMonth()) && (expiry1.getMonth() == expiry2.getMonth())
          && (expiry1.getYear() == expiry2.getYear());
    case DAY_MONTH_YEAR:
      return (expiry1.getDayOfMonth() == expiry2.getDayOfMonth()) && (expiry1.getMonth() == expiry2.getMonth()) && (expiry1.getYear() == expiry2.getYear());
    case MONTH_YEAR:
      return (expiry1.getMonth() == expiry2.getMonth()) && (expiry1.getYear() == expiry2.getYear());
    case YEAR:
      return (expiry1.getYear() == expiry2.getYear());
    default:
      throw new IllegalArgumentException("accuracy");
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:Expiry.java

示例2: 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

示例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() == 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

示例4: presentValueSeasonality

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Tests the present value for curves with seasonal adjustment.
 */
@Test
public void presentValueSeasonality() {
  final InflationIssuerProviderDiscount marketSeason = MulticurveProviderDiscountDataSets.createMarket2(PRICING_DATE);
  final int tenorYear = 5;
  final double notional = 100000000;
  final ZonedDateTime settleDate = ScheduleCalculator.getAdjustedDate(PRICING_DATE, USDLIBOR3M.getSpotLag(), CALENDAR_USD);
  final ZonedDateTime paymentDate = ScheduleCalculator.getAdjustedDate(settleDate, Period.ofYears(tenorYear), BUSINESS_DAY, CALENDAR_USD, USDLIBOR3M.isEndOfMonth());
  final double weightSettle = 1.0 - (settleDate.getDayOfMonth() - 1.0) / settleDate.toLocalDate().lengthOfMonth();
  final double indexStart = weightSettle * 225.964 + (1 - weightSettle) * 225.722;
  final CouponInflationZeroCouponInterpolationDefinition zeroCouponUsdDefinition = CouponInflationZeroCouponInterpolationDefinition.from(settleDate, paymentDate, notional, PRICE_INDEX_US,
      MONTH_LAG, MONTH_LAG, false);
  final CouponInflationZeroCouponInterpolation zeroCouponUsd = (CouponInflationZeroCouponInterpolation) zeroCouponUsdDefinition.toDerivative(PRICING_DATE, priceIndexTS);
  final MultipleCurrencyAmount pvInflation = METHOD.presentValue(zeroCouponUsd, marketSeason.getInflationProvider());
  final double df = MARKET.getCurve(zeroCouponUsd.getCurrency()).getDiscountFactor(zeroCouponUsd.getPaymentTime());
  final double indexMonth0 = marketSeason.getCurve(PRICE_INDEX_US).getPriceIndex(zeroCouponUsd.getReferenceEndTime()[0]);
  final double indexMonth1 = marketSeason.getCurve(PRICE_INDEX_US).getPriceIndex(zeroCouponUsd.getReferenceEndTime()[1]);
  final double finalIndex = zeroCouponUsdDefinition.getWeight() * indexMonth0 + (1 - zeroCouponUsdDefinition.getWeight()) * indexMonth1;
  final double pvExpected = (finalIndex / INDEX_MAY_2011_INT - 1) * df * notional;
  assertEquals("PV in market with seasonal adjustment", pvExpected, pvInflation.getAmount(zeroCouponUsd.getCurrency()), 1E-2);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:CouponInflationZeroCouponInterpolationDiscountingMethodTest.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() == 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

示例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 && 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

示例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() == _dayOfMonth) {
      return new ZonedDateTime[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but their day of month was not the same as that required");
  }
  final List<ZonedDateTime> dates = new ArrayList<>();
  int year = endDate.getYear();
  Month month = startDate.getMonth();
  ZonedDateTime date = startDate.withMonth(month.getValue()).withDayOfMonth(_dayOfMonth);
  if (date.isBefore(startDate)) {
    month = month.plus(1);
    date = date.withMonth(month.getValue());
  }
  year = date.getYear();
  while (!date.isAfter(endDate)) {
    dates.add(date);
    month = month.plus(1);
    if (month == Month.JANUARY) {
      year++;
    }
    date = date.with(LocalDate.of(year, month.getValue(), _dayOfMonth));
  }
  return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:30,代码来源:MonthlyScheduleOnDayCalculator.java

示例8: presentValueSeasonality

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
/**
 * Tests the present value for curves with seasonal adjustment.
 */
public void presentValueSeasonality() {
  final BlackPriceFunction blackFunction = new BlackPriceFunction();
  final InflationIssuerProviderDiscount marketSeason = MulticurveProviderDiscountDataSets.createMarket2(PRICING_DATE);
  final BlackSmileCapInflationZeroCouponProviderDiscount blackInflation = new BlackSmileCapInflationZeroCouponProviderDiscount(marketSeason.getInflationProvider(), BLACK_PARAM);
  final int tenorYear = 5;
  final double notional = 100000000;
  final ZonedDateTime settleDate = ScheduleCalculator.getAdjustedDate(PRICING_DATE, USDLIBOR3M.getSpotLag(), CALENDAR_USD);
  final ZonedDateTime paymentDate = ScheduleCalculator.getAdjustedDate(settleDate, Period.ofYears(tenorYear), BUSINESS_DAY, CALENDAR_USD, USDLIBOR3M.isEndOfMonth());
  final double weightSettle = 1.0 - (paymentDate.getDayOfMonth() - 1.0) / paymentDate.toLocalDate().lengthOfMonth();
  final double indexStart = weightSettle * 225.964 + (1 - weightSettle) * 225.722;
  final CouponInflationZeroCouponInterpolationDefinition zeroCouponUsdDefinition = CouponInflationZeroCouponInterpolationDefinition.from(settleDate, paymentDate, notional, PRICE_INDEX_US,
      MONTH_LAG, MONTH_LAG, false);
  final CapFloorInflationZeroCouponInterpolationDefinition capZeroCouponUsdDefinition = CapFloorInflationZeroCouponInterpolationDefinition.from(zeroCouponUsdDefinition,
      LAST_KNOWN_FIXING_DATE, MATURITY, STRIKE, IS_CAP);

  final ZonedDateTimeDoubleTimeSeries ts = ImmutableZonedDateTimeDoubleTimeSeries.ofUTC(
      new ZonedDateTime[] {DateUtils.getUTCDate(2008, 4, 30), DateUtils.getUTCDate(2008, 5, 31), DateUtils.getUTCDate(2011, 5, 31), DateUtils.getUTCDate(2011, 6, 30),
        DateUtils.getUTCDate(2011, 9, 27),
        DateUtils.getUTCDate(2011, 9, 28) }, new double[] {108.23, 108.64, 225.964, 225.722, 200, 200 });

  final CapFloorInflationZeroCouponInterpolation capZeroCouponUsd = (CapFloorInflationZeroCouponInterpolation) capZeroCouponUsdDefinition.toDerivative(PRICING_DATE, ts);
  final CouponInflationZeroCouponInterpolation zeroCouponUsd = (CouponInflationZeroCouponInterpolation) zeroCouponUsdDefinition.toDerivative(PRICING_DATE, ts);
  final MultipleCurrencyAmount pvInflation = METHOD.presentValue(capZeroCouponUsd, blackInflation);
  final double df = marketSeason.getCurve(zeroCouponUsd.getCurrency()).getDiscountFactor(zeroCouponUsd.getPaymentTime());
  final double indexMonth0 = marketSeason.getCurve(PRICE_INDEX_US).getPriceIndex(zeroCouponUsd.getReferenceEndTime()[0]);
  final double indexMonth1 = marketSeason.getCurve(PRICE_INDEX_US).getPriceIndex(zeroCouponUsd.getReferenceEndTime()[1]);
  final double finalIndex = zeroCouponUsdDefinition.getWeight() * indexMonth0 + (1 - zeroCouponUsdDefinition.getWeight()) * indexMonth1;
  final double forward = finalIndex / indexStart;
  final double timeToMaturity = capZeroCouponUsd.getReferenceEndTime()[1] - capZeroCouponUsd.getLastKnownFixingTime();
  final EuropeanVanillaOption option = new EuropeanVanillaOption(Math.pow(1 + capZeroCouponUsd.getStrike(), capZeroCouponUsd.getMaturity()), timeToMaturity, capZeroCouponUsd.isCap());
  final double volatility = blackInflation.getBlackParameters().getVolatility(capZeroCouponUsd.getReferenceEndTime()[1], capZeroCouponUsd.getStrike());
  final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volatility);
  final Function1D<BlackFunctionData, Double> func = blackFunction.getPriceFunction(option);
  final double pvExpected = df * func.evaluate(dataBlack) * capZeroCouponUsd.getNotional() * capZeroCouponUsd.getPaymentYearFraction();
  assertEquals("PV in market with seasonal adjustment", pvExpected, pvInflation.getAmount(zeroCouponUsd.getCurrency()), 1E-2);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:41,代码来源:CapFloorInflationZeroCouponInterpolationBlackSmileMethodTest.java

示例9: getNextIMMDate

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public static ZonedDateTime getNextIMMDate(final ZonedDateTime date, final Tenor tenor) {
  // If 19th of month (IMM date - 1 day) we need to cycle to next IMM period, as effective date of trade on date t is t + 1
  final ZonedDateTime dateWithTradeAdjustment = ((isIMMDate(date) && date.getDayOfMonth() == TWENTIETH - 1)) ? ZonedDateTime.from(date).plusDays(1) : ZonedDateTime.from(date);
  final ZonedDateTime nextIMMDate = ZonedDateTime.from(IMM_ADJUSTER.adjustInto(dateWithTradeAdjustment)).withDayOfMonth(TWENTIETH); // must be 20th
  return nextIMMDate.plus(tenor.getPeriod());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:7,代码来源:IMMDateGenerator.java

示例10: toDerivative

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * @param date The date to use when converting to the derivative form, not null
 * @param settlementDate The settlement date, not null
 * @param data The index time series
 * @return The derivative form
 */
public BondCapitalIndexedSecurity<Coupon> toDerivative(final ZonedDateTime date, final ZonedDateTime settlementDate, final DoubleTimeSeries<ZonedDateTime> data) {
  ArgumentChecker.notNull(date, "date");
  ArgumentChecker.notNull(settlementDate, "settlement date");
  double settlementTime;
  if (settlementDate.isBefore(date)) {
    settlementTime = 0.0;
  } else {
    settlementTime = TimeCalculator.getTimeBetween(date, settlementDate);
  }
  double lasKnownFixingTime = 0;
  double lasKnownIndexFixing = 0;

  if (!data.isEmpty()) {
    lasKnownFixingTime = TimeCalculator.getTimeBetween(date, data.getLatestTime());
    lasKnownIndexFixing = data.getLatestValue();
  }
  final Annuity<Coupon> nominal = (Annuity<Coupon>) getNominal().toDerivative(date, data);
  final AnnuityDefinition<CouponDefinition> couponDefinition = (AnnuityDefinition<CouponDefinition>) getCoupons().trimBefore(settlementDate);
  final CouponDefinition[] couponExPeriodArray = new CouponDefinition[couponDefinition.getNumberOfPayments()];
  System.arraycopy(couponDefinition.getPayments(), 0, couponExPeriodArray, 0, couponDefinition.getNumberOfPayments());
  if (getExCouponDays() != 0) {
    final ZonedDateTime exDividendDate = ScheduleCalculator.getAdjustedDate(couponDefinition.getNthPayment(0).getPaymentDate(), -getExCouponDays(), getCalendar());
    if (settlementDate.isAfter(exDividendDate)) {
      // Implementation note: Ex-dividend period: the next coupon is not received but its date is required for yield calculation
      couponExPeriodArray[0] = new CouponFixedDefinition(couponDefinition.getNthPayment(0), 0.0);
    }
  }
  final AnnuityDefinition<PaymentDefinition> couponDefinitionExPeriod = new AnnuityDefinition<PaymentDefinition>(couponExPeriodArray, getCalendar());
  final Annuity<Coupon> couponStandard = (Annuity<Coupon>) couponDefinitionExPeriod.toDerivative(date, data);
  final Annuity<Coupon> nominalStandard = nominal.trimBefore(settlementTime);
  final double accruedInterest = accruedInterest(settlementDate);
  final double factorSpot = getDayCount().getAccruedInterest(couponDefinition.getNthPayment(0).getAccrualStartDate(), settlementDate, couponDefinition.getNthPayment(0).getAccrualEndDate(), 1.0,
      _couponPerYear);
  final double factorPeriod = getDayCount().getAccruedInterest(couponDefinition.getNthPayment(0).getAccrualStartDate(), couponDefinition.getNthPayment(0).getAccrualEndDate(),
      couponDefinition.getNthPayment(0).getAccrualEndDate(), 1.0, _couponPerYear);
  final double factorToNextCoupon = (factorPeriod - factorSpot) / factorPeriod;
  final double nbDayToSpot = couponDefinition.getNthPayment(0).getAccrualEndDate().getDayOfYear() - settlementDate.getDayOfYear();
  final double nbDaysPeriod = couponDefinition.getNthPayment(0).getAccrualEndDate().getDayOfYear() - couponDefinition.getNthPayment(0).getAccrualStartDate().getDayOfYear();
  final double ratioPeriodToNextCoupon = nbDayToSpot / nbDaysPeriod;
  final CouponInflationDefinition nominalLast = getNominal().getNthPayment(getNominal().getNumberOfPayments() - 1);
  final ZonedDateTime settlementDate2 = settlementDate.isBefore(date) ? date : settlementDate;
  final double notional = nominalLast.getNotional() * (settlementDate.isBefore(date) ? 0.0 : 1.0);
  final CouponInflationDefinition settlementDefinition = nominalLast.with(settlementDate2, nominalLast.getAccrualStartDate(), settlementDate2, notional);
  final Coupon settlement = settlementDefinition.toDerivative(date, data); // TODO: use hts
  double indexRatio = 1;
  if (settlementDefinition instanceof CouponInflationZeroCouponInterpolationGearingDefinition) {
    final int monthLag = ((CouponInflationZeroCouponInterpolationGearingDefinition) settlementDefinition).getMonthLag();
    final ZonedDateTime[] referenceStartDates = new ZonedDateTime[2];
    final ZonedDateTime refInterpolatedStartDate = settlementDate2.minusMonths(monthLag);
    referenceStartDates[0] = refInterpolatedStartDate.with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0).withSecond(0).withNano(0);
    referenceStartDates[1] = referenceStartDates[0].plusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0).withSecond(0).withNano(0);
    final double indexEnd0 = data.getValue(referenceStartDates[0]);
    final double indexEnd1 = data.getValue(referenceStartDates[1]);
    final double weight = 1.0 - (settlementDate2.getDayOfMonth() - 1.0) / settlementDate2.toLocalDate().lengthOfMonth();
    final double indexEndValue = weight * indexEnd0 + (1 - weight) * indexEnd1;
    indexRatio = indexEndValue / _indexStartValue;
  } else if (settlementDefinition instanceof CouponInflationZeroCouponMonthlyGearingDefinition) {
    indexRatio = lasKnownIndexFixing / _indexStartValue;
  } else {
    throw new OpenGammaRuntimeException("Unsupported coupon type " + getNominal().getNthPayment(0).getClass());
  }
  return new BondCapitalIndexedSecurity<>(nominalStandard, couponStandard, settlementTime, accruedInterest, 
      factorToNextCoupon, ratioPeriodToNextCoupon, _yieldConvention, _couponPerYear,
      settlement, _indexStartValue, lasKnownIndexFixing, lasKnownFixingTime, indexRatio, getIssuerEntity());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:72,代码来源:BondCapitalIndexedSecurityDefinition.java

示例11: getSchedule

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public static ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate, final int periodsPerYear, final boolean endOfMonth, final boolean fromEnd,
    final boolean generateRecursive) {
  Validate.notNull(startDate, "start date");
  Validate.notNull(endDate, "end date");
  Validate.isTrue(periodsPerYear > 0);
  ZonedDateTime[] result = null;
  if (periodsPerYear == 1) {
    if (endOfMonth) {
      if (fromEnd && endDate.getDayOfMonth() == endDate.toLocalDate().lengthOfMonth()) {
        result = ScheduleCalculatorFactory.ANNUAL_EOM_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      } else if (startDate.getDayOfMonth() == startDate.toLocalDate().lengthOfMonth()) {
        result = ScheduleCalculatorFactory.ANNUAL_EOM_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      } else {
        result = ScheduleCalculatorFactory.ANNUAL_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      }
    } else {
      result = ScheduleCalculatorFactory.ANNUAL_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
    }
  } else if (periodsPerYear == 2) {
    if (endOfMonth) {
      if (fromEnd && endDate.getDayOfMonth() == endDate.toLocalDate().lengthOfMonth()) {
        result = ScheduleCalculatorFactory.SEMI_ANNUAL_EOM_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      } else if (startDate.getDayOfMonth() == startDate.toLocalDate().lengthOfMonth()) {
        result = ScheduleCalculatorFactory.SEMI_ANNUAL_EOM_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      } else {
        result = ScheduleCalculatorFactory.SEMI_ANNUAL_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      }
    } else {
      result = ScheduleCalculatorFactory.SEMI_ANNUAL_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
    }
  } else if (periodsPerYear == 4) {
    if (endOfMonth) {
      if (fromEnd && endDate.getDayOfMonth() == endDate.toLocalDate().lengthOfMonth()) {
        result = ScheduleCalculatorFactory.QUARTERLY_EOM_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      } else if (startDate.getDayOfMonth() == startDate.toLocalDate().lengthOfMonth()) {
        result = ScheduleCalculatorFactory.QUARTERLY_EOM_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      } else {
        result = ScheduleCalculatorFactory.QUARTERLY_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      }
    } else {
      result = ScheduleCalculatorFactory.QUARTERLY_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
    }
  } else if (periodsPerYear == 12) {
    if (endOfMonth) {
      if (fromEnd && endDate.getDayOfMonth() == endDate.toLocalDate().lengthOfMonth()) {
        result = ScheduleCalculatorFactory.END_OF_MONTH_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      } else if (startDate.getDayOfMonth() == startDate.toLocalDate().lengthOfMonth()) {
        result = ScheduleCalculatorFactory.END_OF_MONTH_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      } else {
        result = ScheduleCalculatorFactory.MONTHLY_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
      }
    } else {
      result = ScheduleCalculatorFactory.MONTHLY_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
    }
  } else if (periodsPerYear == 52) {
    if (endOfMonth) {
      throw new IllegalArgumentException("Cannot get EOM series for weekly frequency");
    }
    result = ScheduleCalculatorFactory.WEEKLY_CALCULATOR.getSchedule(startDate, endDate, fromEnd, generateRecursive);
  } else if (periodsPerYear == 365 || periodsPerYear == 366) {
    if (endOfMonth) {
      throw new IllegalArgumentException("Cannot get EOM series for daily frequency");
    }
    result = ScheduleCalculatorFactory.DAILY_CALCULATOR.getSchedule(startDate, endDate);
  }
  Validate.notNull(result, "result");
  return result;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:69,代码来源:ScheduleFactory.java

示例12: from

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Constructor for zero-coupon inflation coupon.
 * @param currency The coupon currency.
 * @param paymentDate The payment date.
 * @param accrualStartDate Start date of the accrual period.
 * @param accrualEndDate End date of the accrual period.
 * @param paymentYearFraction Accrual factor of the accrual period.
 * @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 for the standard product.
 * @param monthLag The lag in month between the index validity and the coupon dates for the actual product.
 * @param referenceStartDate The reference date for the index at the coupon start.
 * @param indexStartValue The index value at the start of the coupon.
 * @param referenceEndDate The reference date for the index at the coupon end.
 * @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 Currency currency, final ZonedDateTime paymentDate, final ZonedDateTime accrualStartDate,
    final ZonedDateTime accrualEndDate, final double paymentYearFraction, final double notional, final IndexPrice priceIndex, final int conventionalMonthLag,
    final int monthLag, final ZonedDateTime[] referenceStartDate, final double indexStartValue, final ZonedDateTime[] referenceEndDate, final boolean payNotional, final double factor) {

  ArgumentChecker.notNull(referenceStartDate, "Reference start date");
  ArgumentChecker.notNull(referenceEndDate, "Reference end date");

  final double weight = 1.0 - (paymentDate.getDayOfMonth() - 1.0) / paymentDate.toLocalDate().lengthOfMonth();
  return new CouponInflationZeroCouponInterpolationGearingDefinition(currency, paymentDate, accrualStartDate, accrualEndDate, 1.0, notional, priceIndex,
      conventionalMonthLag, monthLag, referenceStartDate, indexStartValue, referenceEndDate, payNotional, weight, factor);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:30,代码来源:CouponInflationZeroCouponInterpolationGearingDefinition.java

示例13: from

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Builder from all the cap/floor details except weights which are calculated using the payment 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 lastKnownFixingDate The fixing date (always the first of a month) of the last known fixing.
 * @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 referenceStartDate The reference dates for the index at the coupon start.
 * @param referenceEndDate The reference dates for the index at the coupon end.
 * @param strike The strike
 * @param isCap The cap/floor flag.
 * @return The cap/floor.
 */
public static CapFloorInflationYearOnYearInterpolationDefinition from(final ZonedDateTime accrualStartDate, final ZonedDateTime paymentDate, final double notional,
    final IndexPrice priceIndex, final ZonedDateTime lastKnownFixingDate, final int conventionalMonthLag, final int monthLag, final ZonedDateTime[] referenceStartDate,
    final ZonedDateTime[] referenceEndDate, final double strike, final boolean isCap) {
  Validate.notNull(priceIndex, "Price index");
  final double weightStart;
  final double weightEnd;
  weightStart = 1.0 - (paymentDate.getDayOfMonth() - 1.0) / paymentDate.toLocalDate().lengthOfMonth();
  weightEnd = weightStart;
  return new CapFloorInflationYearOnYearInterpolationDefinition(priceIndex.getCurrency(), paymentDate, accrualStartDate, paymentDate, 1.0,
      notional, priceIndex, lastKnownFixingDate, conventionalMonthLag, monthLag, referenceStartDate, referenceEndDate, weightStart,
      weightEnd, strike, isCap);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:28,代码来源:CapFloorInflationYearOnYearInterpolationDefinition.java

示例14: from

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Builder for inflation year on year coupon based on an inflation lag and the index publication lag. The fixing date is the publication lag after the last reference month.
 * The index start value is calculated from a time series. The index value required for the coupon should be in the time series.
 * @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 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).
 * @return The inflation zero-coupon.
 */
public static CouponInflationYearOnYearInterpolationDefinition from(final ZonedDateTime accrualStartDate, final ZonedDateTime paymentDate, final double notional,
    final IndexPrice priceIndex, final int conventionalmonthLag, final int monthLag, final boolean payNotional) {
  final ZonedDateTime refInterpolatedDateStart = accrualStartDate;
  final ZonedDateTime refInterpolatedDateEnd = paymentDate;

  final double weightStart = 1.0 - (refInterpolatedDateStart.getDayOfMonth() - 1.0) / refInterpolatedDateStart.toLocalDate().lengthOfMonth();
  final double weightEnd = 1.0 - (refInterpolatedDateEnd.getDayOfMonth() - 1.0) / refInterpolatedDateEnd.toLocalDate().lengthOfMonth();

  return from(accrualStartDate, paymentDate, notional, priceIndex, conventionalmonthLag, monthLag, payNotional, weightStart, weightEnd);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:CouponInflationYearOnYearInterpolationDefinition.java

示例15: from

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Builder for inflation year on year coupon based on an inflation lag and the index publication lag. The fixing date is the publication lag after the last reference month.
 * The index start value is calculated from a time series. The index value required for the coupon should be in the time series.
 * @param factor the additive factor
 * @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 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).
 * @return The inflation zero-coupon.
 */
public static CouponInflationYearOnYearInterpolationWithMarginDefinition from(final double factor, final ZonedDateTime accrualStartDate, final ZonedDateTime paymentDate, final double notional,
    final IndexPrice priceIndex, final int conventionalmonthLag, final int monthLag, final boolean payNotional) {
  final ZonedDateTime refInterpolatedDateStart = accrualStartDate;
  final ZonedDateTime refInterpolatedDateEnd = paymentDate;

  final double weightStart = 1.0 - (refInterpolatedDateStart.getDayOfMonth() - 1.0) / refInterpolatedDateStart.toLocalDate().lengthOfMonth();
  final double weightEnd = 1.0 - (refInterpolatedDateEnd.getDayOfMonth() - 1.0) / refInterpolatedDateEnd.toLocalDate().lengthOfMonth();

  return from(factor, accrualStartDate, paymentDate, notional, priceIndex, conventionalmonthLag, monthLag, payNotional, weightStart, weightEnd);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:CouponInflationYearOnYearInterpolationWithMarginDefinition.java


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