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


Java ZonedDateTime.isBefore方法代码示例

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


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

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

示例2: toDerivative

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * {@inheritDoc} The definition is responsible for constructing a view of the variance swap as of a particular date.
 * In particular, it resolves calendars. The variance swap needs an array of observations, as well as its *expected* length.
 * The actual number of observations may be less than that expected at trade inception because of a market disruption event.
 * ( For an example of a market disruption event, see http://cfe.cboe.com/Products/Spec_VT.aspx )
 */
@Override
public VarianceSwap toDerivative(final ZonedDateTime date, final DoubleTimeSeries<LocalDate> underlyingTimeSeries) {
  ArgumentChecker.notNull(date, "date");
  ArgumentChecker.notNull(underlyingTimeSeries, "underlyingTimeSeries");
  final double timeToObsStart = TimeCalculator.getTimeBetween(date, _obsStartDate);
  final double timeToObsEnd = TimeCalculator.getTimeBetween(date, _obsEndDate);
  final double timeToSettlement = TimeCalculator.getTimeBetween(date, _settlementDate);
  DoubleTimeSeries<LocalDate> realizedTS;
  if (timeToObsStart > 0) {
    realizedTS = ImmutableLocalDateDoubleTimeSeries.EMPTY_SERIES;
  } else {
    realizedTS = underlyingTimeSeries.subSeries(_obsStartDate.toLocalDate(), true, date.toLocalDate(), false);
  }
  final double[] observations = realizedTS.valuesArrayFast();
  final double[] observationWeights = {}; // TODO Case 2011-06-29 Calendar Add functionality for non-trivial weighting of observations
  //if we view this option on some date between the observation start and end dates, then the observation on that particular
  //date will not have been made (observations are closing levels) 
  final int nObservations = date.isAfter(_obsEndDate) ? _nObsExpected : (date.isBefore(_obsStartDate) ? 0 : getDaysBetween(_obsStartDate, date, _calendar));
  final int nObsDisrupted = nObservations - observations.length;
  ArgumentChecker.isTrue(nObsDisrupted >= 0, "Have more observations {} than good business days {}", observations.length, nObservations);
  return new VarianceSwap(timeToObsStart, timeToObsEnd, timeToSettlement, _varStrike, _varNotional, _currency, _annualizationFactor, _nObsExpected, nObsDisrupted, observations, observationWeights);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:29,代码来源:VarianceSwapDefinition.java

示例3: getAccruedInterest

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Calculates the accrued interest for a {@code ZonedDateTime}.
 * 
 * @param dayCount  the day count convention, not null
 * @param settlementDate  the settlement date, not null
 * @param nominalDates  the nominalDates, not null, no null elements
 * @param coupon  the coupon value
 * @param paymentsPerYear  the number of payments per year, one, two, three, four, six or twelve
 * @param isEndOfMonthConvention  whether to use end of month rules
 * @param exDividendDays the number of ex-dividend days
 * @param index The index of the previous coupon in the nominalDates array
 * @param calendar The working day calendar to be used in calculating ex-dividend dates, not null
 * @return the accrued interest
 */
public static double getAccruedInterest(final DayCount dayCount, final ZonedDateTime settlementDate, final ZonedDateTime[] nominalDates, final double coupon, final double paymentsPerYear,
    final boolean isEndOfMonthConvention, final int exDividendDays, final int index, final Calendar calendar) {
  Validate.notNull(dayCount, "day-count");
  Validate.notNull(settlementDate, "date");
  Validate.noNullElements(nominalDates, "nominalDates");
  Validate.notNull(calendar, "calendar");
  Validate.isTrue(paymentsPerYear > 0);
  Validate.isTrue(exDividendDays >= 0);
  final int length = nominalDates.length;
  Validate.isTrue(index >= 0 && index < length);
  final double accruedInterest = getAccruedInterest(dayCount, index, length, nominalDates[index], settlementDate, nominalDates[index + 1], coupon, paymentsPerYear, isEndOfMonthConvention);
  ZonedDateTime exDividendDate = nominalDates[index + 1];
  for (int i = 0; i < exDividendDays; i++) {
    while (!calendar.isWorkingDay(exDividendDate.toLocalDate())) {
      exDividendDate = exDividendDate.minusDays(1);
    }
    exDividendDate = exDividendDate.minusDays(1);
  }
  if (exDividendDays != 0 && exDividendDate.isBefore(settlementDate)) {
    return accruedInterest - coupon;
  }
  return accruedInterest;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:38,代码来源:AccruedInterestCalculator.java

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

示例5: getCarrLeeData

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
protected CarrLeeFXData getCarrLeeData(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final FXMatrix fxMatrix) {
  final FXVolatilitySwapSecurity security = (FXVolatilitySwapSecurity) target.getTrade().getSecurity();
  final MulticurveProviderInterface data = getMergedProviders(inputs, fxMatrix);
  final SmileDeltaTermStructureParametersStrikeInterpolation volatilitySurface = (SmileDeltaTermStructureParametersStrikeInterpolation) inputs.getValue(STANDARD_VOLATILITY_SURFACE_DATA);
  final Pair<Currency, Currency> currencyPair = Pairs.of(security.getBaseCurrency(), security.getCounterCurrency());
  final Clock snapshotClock = executionContext.getValuationClock();
  final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
  if (now.isBefore(security.getFirstObservationDate())) {
    return new CarrLeeFXData(currencyPair, volatilitySurface, data);
  }
  final double realizedVariance = (Double) inputs.getValue(REALIZED_VARIANCE);
  return new CarrLeeFXData(currencyPair, volatilitySurface, data, realizedVariance);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:15,代码来源:CarrLeeFXVolatilitySwapFunction.java

示例6: getPayoff

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public double getPayoff(final StandardOptionDataBundle data, final Double optionPrice) {
  final ZonedDateTime date = data.getDate();
  if (date.isBefore(getStartTime().getExpiry())) {
    throw new IllegalArgumentException("Cannot get strike before start time: it has not been defined");
  }
  final double spot = data.getSpot();
  final double alpha = getAlpha();
  final double strike = spot * alpha;
  return isCall() ? Math.max(0, spot - strike) : Math.max(0, strike - spot);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:12,代码来源:ForwardStartOptionDefinition.java

示例7: compare

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public int compare(final ZonedDateTime d1, final ZonedDateTime d2, final Period tolerance) {
  final ZonedDateTime dLow = d1.minus(tolerance);
  final ZonedDateTime dHigh = d1.plus(tolerance);
  if (d1.equals(d2) || (d2.isAfter(dLow) && d2.isBefore(dHigh))) {
    return 0;
  }
  return d1.isBefore(d2) ? -1 : 1;

}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:11,代码来源:ZonedDateTimeLabelledMatrix1D.java

示例8: CouponONCompoundedDefinition

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Constructor from all the coupon details.
 * @param currency The payment currency.
 * @param paymentDate Coupon 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 index The OIS-like index on which the coupon fixes.
 * @param fixingPeriodStartDate The start date of the fixing period.
 * @param fixingPeriodEndDate The end date of the fixing period.
 * @param calendar The holiday calendar for the overnight index.
 */
public CouponONCompoundedDefinition(final Currency currency, final ZonedDateTime paymentDate, final ZonedDateTime accrualStartDate, final ZonedDateTime accrualEndDate,
    final double paymentYearFraction, final double notional, final IndexON index, final ZonedDateTime fixingPeriodStartDate, final ZonedDateTime fixingPeriodEndDate,
    final Calendar calendar) {
  super(currency, paymentDate, accrualStartDate, accrualEndDate, paymentYearFraction, notional);
  ArgumentChecker.notNull(index, "CouponOISDefinition: index");
  ArgumentChecker.notNull(fixingPeriodStartDate, "CouponOISDefinition: fixingPeriodStartDate");
  ArgumentChecker.notNull(fixingPeriodEndDate, "CouponOISDefinition: fixingPeriodEndDate");
  ArgumentChecker.isTrue(currency.equals(index.getCurrency()), "Coupon and index currencies are not compatible. Expected to be the same");
  _index = index;

  final List<ZonedDateTime> fixingDateList = new ArrayList<>();
  final List<Double> fixingAccrualFactorList = new ArrayList<>();

  ZonedDateTime currentDate = fixingPeriodStartDate;
  fixingDateList.add(currentDate);
  ZonedDateTime nextDate;
  while (currentDate.isBefore(fixingPeriodEndDate)) {
    nextDate = ScheduleCalculator.getAdjustedDate(currentDate, 1, calendar);
    fixingDateList.add(nextDate);
    fixingAccrualFactorList.add(index.getDayCount().getDayCountFraction(currentDate, nextDate, calendar));
    currentDate = nextDate;
  }
  _fixingPeriodDates = fixingDateList.toArray(new ZonedDateTime[fixingDateList.size()]);
  _fixingPeriodAccrualFactors = new double[fixingAccrualFactorList.size()];
  for (int i = 0; i < fixingAccrualFactorList.size(); i++) {
    _fixingPeriodAccrualFactors[i] = fixingAccrualFactorList.get(i);
  }
  _calendar = calendar;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:43,代码来源:CouponONCompoundedDefinition.java

示例9: CouponONSpreadDefinition

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Constructor from all the coupon details.
 * @param currency The payment currency.
 * @param paymentDate Coupon 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 index The OIS-like index on which the coupon fixes.
 * @param fixingPeriodStartDate The start date of the fixing period.
 * @param fixingPeriodEndDate The end date of the fixing period.
 * @param calendar The holiday calendar for the overnight index.
 * @param spread The spread
 */
public CouponONSpreadDefinition(final Currency currency, final ZonedDateTime paymentDate, final ZonedDateTime accrualStartDate, 
    final ZonedDateTime accrualEndDate, final double paymentYearFraction, final double notional, final IndexON index, 
    final ZonedDateTime fixingPeriodStartDate, final ZonedDateTime fixingPeriodEndDate, final Calendar calendar, 
    final double spread) {
  super(currency, paymentDate, accrualStartDate, accrualEndDate, paymentYearFraction, notional);
  ArgumentChecker.notNull(index, "CouponOISDefinition: index");
  ArgumentChecker.notNull(fixingPeriodStartDate, "CouponOISDefinition: fixingPeriodStartDate");
  ArgumentChecker.notNull(fixingPeriodEndDate, "CouponOISDefinition: fixingPeriodEndDate");
  ArgumentChecker.isTrue(currency.equals(index.getCurrency()), "Coupon and index currencies are not compatible. Expected to be the same");
  _index = index;

  final List<ZonedDateTime> fixingDateList = new ArrayList<>();
  final List<Double> fixingAccrualFactorList = new ArrayList<>();

  ZonedDateTime currentDate = fixingPeriodStartDate;
  fixingDateList.add(currentDate);
  ZonedDateTime nextDate;
  while (currentDate.isBefore(fixingPeriodEndDate)) {
    nextDate = ScheduleCalculator.getAdjustedDate(currentDate, 1, calendar);
    fixingDateList.add(nextDate);
    fixingAccrualFactorList.add(index.getDayCount().getDayCountFraction(currentDate, nextDate, calendar));
    currentDate = nextDate;
  }
  _fixingPeriodDate = fixingDateList.toArray(new ZonedDateTime[fixingDateList.size()]);
  _fixingPeriodAccrualFactor = fixingAccrualFactorList.toArray(new Double[fixingAccrualFactorList.size()]);
  _spread = spread;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:42,代码来源:CouponONSpreadDefinition.java

示例10: CouponONArithmeticAverageDefinition

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Constructor from all the coupon details.
 * @param currency The payment currency.
 * @param paymentDate Coupon payment date.
 * @param accrualStartDate Start date of the accrual period.
 * @param accrualEndDate End date of the accrual period.
 * @param paymentAccrualFactor Accrual factor of the accrual period.
 * @param notional Coupon notional.
 * @param index The OIS-like index on which the coupon fixes.
 * @param fixingPeriodStartDate The start date of the fixing period.
 * @param fixingPeriodEndDate The end date of the fixing period.
 * @param calendar The holiday calendar for the overnight leg.
 */
public CouponONArithmeticAverageDefinition(final Currency currency, final ZonedDateTime paymentDate, final ZonedDateTime accrualStartDate, final ZonedDateTime accrualEndDate,
    final double paymentAccrualFactor, final double notional, final IndexON index, final ZonedDateTime fixingPeriodStartDate, final ZonedDateTime fixingPeriodEndDate,
    final Calendar calendar) {
  super(currency, paymentDate, accrualStartDate, accrualEndDate, paymentAccrualFactor, notional);
  ArgumentChecker.notNull(index, "CouponArithmeticAverageONDefinition: index");
  ArgumentChecker.notNull(fixingPeriodStartDate, "CouponArithmeticAverageONDefinition: fixingPeriodStartDate");
  ArgumentChecker.notNull(fixingPeriodEndDate, "CouponArithmeticAverageONDefinition: fixingPeriodEndDate");
  ArgumentChecker.isTrue(currency.equals(index.getCurrency()), "Coupon and index currencies are not compatible. Expected to be the same");
  _index = index;
  final List<ZonedDateTime> fixingStartDateList = new ArrayList<>();
  final List<ZonedDateTime> fixingEndDateList = new ArrayList<>();
  final List<Double> fixingAccrualFactorList = new ArrayList<>();
  ZonedDateTime currentDate = fixingPeriodStartDate;
  fixingStartDateList.add(currentDate);
  ZonedDateTime nextDate;
  while (currentDate.isBefore(fixingPeriodEndDate)) {
    nextDate = ScheduleCalculator.getAdjustedDate(currentDate, 1, calendar);
    fixingStartDateList.add(nextDate);
    fixingEndDateList.add(nextDate);
    fixingAccrualFactorList.add(index.getDayCount().getDayCountFraction(currentDate, nextDate, calendar));
    currentDate = nextDate;
  }
  fixingStartDateList.remove(fixingPeriodEndDate);
  _fixingPeriodStartDates = fixingStartDateList.toArray(new ZonedDateTime[fixingStartDateList.size()]);
  _fixingPeriodEndDates = fixingEndDateList.toArray(new ZonedDateTime[fixingEndDateList.size()]);
  _fixingPeriodAccrualFactors = ArrayUtils.toPrimitive(fixingAccrualFactorList.toArray(new Double[fixingAccrualFactorList.size()]));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:41,代码来源:CouponONArithmeticAverageDefinition.java

示例11: withRateCutOff

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Constructor with the rate cut off (the last n=rateCutoff fixings are the same) from all the coupon details.
 * @param currency The payment currency.
 * @param paymentDate Coupon payment date.
 * @param accrualStartDate Start date of the accrual period.
 * @param accrualEndDate End date of the accrual period.
 * @param paymentAccrualFactor Accrual factor of the accrual period.
 * @param notional Coupon notional.
 * @param index The OIS-like index on which the coupon fixes.
 * @param fixingPeriodStartDate The start date of the fixing period.
 * @param fixingPeriodEndDate The end date of the fixing period.
 * @param calendar The holiday calendar for the overnight leg.
 * @param  rateCutoff The rate cut off should be bigger than 1,and smaller than the number of period (which is the number of open days between the two fixing periods). 1 is for the normal case.
 * @return The OIS coupon.
 */
public static CouponONArithmeticAverageDefinition withRateCutOff(final Currency currency, final ZonedDateTime paymentDate, final ZonedDateTime accrualStartDate, final ZonedDateTime accrualEndDate,
    final double paymentAccrualFactor, final double notional, final IndexON index, final ZonedDateTime fixingPeriodStartDate, final ZonedDateTime fixingPeriodEndDate,
    final Calendar calendar, final int rateCutoff) {
  ArgumentChecker.notNull(index, "CouponArithmeticAverageONDefinition: index");
  ArgumentChecker.notNull(fixingPeriodStartDate, "CouponArithmeticAverageONDefinition: fixingPeriodStartDate");
  ArgumentChecker.notNull(fixingPeriodEndDate, "CouponArithmeticAverageONDefinition: fixingPeriodEndDate");
  ArgumentChecker.isTrue(currency.equals(index.getCurrency()), "Coupon and index currencies are not compatible. Expected to be the same");
  ArgumentChecker.isTrue(rateCutoff >= 1, "");
  if (rateCutoff == 1) {
    return new CouponONArithmeticAverageDefinition(currency, paymentDate, accrualStartDate, accrualEndDate, paymentAccrualFactor, notional, index, fixingPeriodStartDate, fixingPeriodEndDate,
        calendar);
  }
  final List<ZonedDateTime> fixingStartDateList = new ArrayList<>();
  final List<ZonedDateTime> fixingEndDateList = new ArrayList<>();
  final List<Double> fixingAccrualFactorList = new ArrayList<>();
  ZonedDateTime currentDate = fixingPeriodStartDate;
  fixingStartDateList.add(currentDate);
  ZonedDateTime nextDate;
  final ZonedDateTime fixingPeriodEndDateMinusRateCutOff = ScheduleCalculator.getAdjustedDate(fixingPeriodEndDate, -rateCutoff + 1, calendar);
  ArgumentChecker.isTrue(fixingPeriodEndDateMinusRateCutOff.isAfter(fixingPeriodStartDate), "");
  while (currentDate.isBefore(fixingPeriodEndDateMinusRateCutOff)) {
    nextDate = ScheduleCalculator.getAdjustedDate(currentDate, 1, calendar);
    fixingStartDateList.add(nextDate);
    fixingEndDateList.add(nextDate);
    fixingAccrualFactorList.add(index.getDayCount().getDayCountFraction(currentDate, nextDate, calendar));
    currentDate = nextDate;
  }
  fixingStartDateList.remove(fixingPeriodEndDateMinusRateCutOff);
  for (int i = 0; i < rateCutoff - 1; i++) {
    fixingStartDateList.add(ScheduleCalculator.getAdjustedDate(currentDate, -1, calendar));
    fixingEndDateList.add(currentDate);
  }
  final ZonedDateTime[] fixingPeriodStartDates = fixingStartDateList.toArray(new ZonedDateTime[fixingStartDateList.size()]);
  final ZonedDateTime[] fixingPeriodEndDates = fixingEndDateList.toArray(new ZonedDateTime[fixingEndDateList.size()]);
  final double[] fixingPeriodAccrualFactors = ArrayUtils.toPrimitive(fixingAccrualFactorList.toArray(new Double[fixingAccrualFactorList.size()]));
  return new CouponONArithmeticAverageDefinition(currency, paymentDate, accrualStartDate, accrualEndDate, paymentAccrualFactor, notional, index, fixingPeriodStartDates, fixingPeriodEndDates,
      fixingPeriodAccrualFactors, calendar);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:54,代码来源:CouponONArithmeticAverageDefinition.java

示例12: CouponONArithmeticAverageSpreadDefinition

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Constructor from all the coupon details.
 * @param currency The payment currency.
 * @param paymentDate Coupon 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 index The OIS-like index on which the coupon fixes.
 * @param fixingPeriodStartDate The start date of the fixing period.
 * @param fixingPeriodEndDate The end date of the fixing period.
 * @param spread The spread rate paid above the arithmetic average.
 * @param calendar The holiday calendar for the overnight index.
 */
public CouponONArithmeticAverageSpreadDefinition(final Currency currency, final ZonedDateTime paymentDate, final ZonedDateTime accrualStartDate, final ZonedDateTime accrualEndDate,
    final double paymentYearFraction, final double notional, final IndexON index, final ZonedDateTime fixingPeriodStartDate, final ZonedDateTime fixingPeriodEndDate, final double spread,
    final Calendar calendar) {
  super(currency, paymentDate, accrualStartDate, accrualEndDate, paymentYearFraction, notional);
  ArgumentChecker.notNull(index, "CouponOISDefinition: index");
  ArgumentChecker.notNull(fixingPeriodStartDate, "CouponOISDefinition: fixingPeriodStartDate");
  ArgumentChecker.notNull(fixingPeriodEndDate, "CouponOISDefinition: fixingPeriodEndDate");
  ArgumentChecker.isTrue(currency.equals(index.getCurrency()), "Coupon and index currencies are not compatible. Expected to be the same");
  _index = index;
  final List<ZonedDateTime> fixingDateList = new ArrayList<>();
  final List<Double> fixingAccrualFactorList = new ArrayList<>();
  ZonedDateTime currentDate = fixingPeriodStartDate;
  fixingDateList.add(currentDate);
  ZonedDateTime nextDate;
  while (currentDate.isBefore(fixingPeriodEndDate)) {
    nextDate = ScheduleCalculator.getAdjustedDate(currentDate, 1, calendar);
    fixingDateList.add(nextDate);
    final double af = index.getDayCount().getDayCountFraction(currentDate, nextDate, calendar);
    fixingAccrualFactorList.add(af);
    currentDate = nextDate;
  }
  _fixingPeriodDates = fixingDateList.toArray(new ZonedDateTime[fixingDateList.size()]);
  _fixingPeriodAccrualFactors = ArrayUtils.toPrimitive(fixingAccrualFactorList.toArray(new Double[fixingAccrualFactorList.size()]));
  _spread = spread;
  _spreadAmount = spread * paymentYearFraction * notional;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:41,代码来源:CouponONArithmeticAverageSpreadDefinition.java

示例13: toDerivative

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * @param date The valuation date, not null
 * @param indexFixingTS The index fixing time series, not null
 * @param settlementDate The settlement date, not null
 * @return The security
 */
public BondIborSecurity toDerivative(final ZonedDateTime date, final DoubleTimeSeries<ZonedDateTime> indexFixingTS, final ZonedDateTime settlementDate) {
  ArgumentChecker.notNull(date, "date");
  ArgumentChecker.notNull(indexFixingTS, "fixing time series");
  ArgumentChecker.notNull(settlementDate, "settlement date");
  double settlementTime;
  if (settlementDate.isBefore(date)) {
    settlementTime = 0.0;
  } else {
    settlementTime = TimeCalculator.getTimeBetween(date, settlementDate);
  }
  final AnnuityPaymentFixed nominal = (AnnuityPaymentFixed) getNominal().toDerivative(date);
  final Annuity<Coupon> coupon = (Annuity<Coupon>) getCoupons().toDerivative(date, indexFixingTS);
  return new BondIborSecurity(nominal.trimBefore(settlementTime), coupon.trimBefore(settlementTime), settlementTime);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:BondIborSecurityDefinition.java

示例14: 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 BondInterestIndexedSecurity<PaymentFixed, 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);
  }
  final Annuity<PaymentFixed> nominal = (Annuity<PaymentFixed>) 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<PaymentFixed> 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 PaymentFixedDefinition nominalLast = getNominal().getNthPayment(getNominal().getNumberOfPayments() - 1);
  final ZonedDateTime settlementDate2 = settlementDate.isBefore(date) ? date : settlementDate;
  final double notional = settlementDate.isBefore(date) ? 0.0 : 1.0;
  final PaymentFixedDefinition settlementDefinition = new PaymentFixedDefinition(nominalLast.getCurrency(), settlementDate2, notional);
  final PaymentFixed settlement = settlementDefinition.toDerivative(date);
  return new BondInterestIndexedSecurity<>(nominalStandard, couponStandard, settlementTime, accruedInterest, factorToNextCoupon, _yieldConvention,
      _couponPerYear, settlement, getIssuerEntity(), _priceIndex);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:44,代码来源:BondInterestIndexedSecurityDefinition.java

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


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