本文整理汇总了Java中org.threeten.bp.ZonedDateTime.minusMonths方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.minusMonths方法的具体用法?Java ZonedDateTime.minusMonths怎么用?Java ZonedDateTime.minusMonths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.minusMonths方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 paymentDate The payment date.
* @param accrualStartDate Start date of the accrual period.
* @param accrualEndDate End date of the accrual period.
* @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 paymentDate, final ZonedDateTime accrualStartDate,
final ZonedDateTime accrualEndDate, 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()).withHour(0).withMinute(0);
referenceStartDates[1] = referenceStartDates[0].plusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0);
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, accrualEndDate, 1.0, notional,
priceIndex, conventionalMonthLag, monthLag, referenceStartDates, indexStartValue, referenceEndDates, payNotional, factor);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:30,代码来源:CouponInflationZeroCouponInterpolationGearingDefinition.java
示例2: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Coupon toDerivative(final ZonedDateTime date, final DoubleTimeSeries<ZonedDateTime> priceIndexTimeSeries) {
ArgumentChecker.notNull(date, "date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
final LocalDate dayConversion = date.toLocalDate();
final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
final LocalDate dayFixing = getReferenceEndDate().toLocalDate();
if (dayConversion.isAfter(dayFixing)) {
final Double fixedEndIndex = priceIndexTimeSeries.getValue(getReferenceEndDate());
if (fixedEndIndex != null) {
final Double fixedStartIndex = priceIndexTimeSeries.getValue(getReferenceStartDate());
final Double fixedRate = (fixedEndIndex / fixedStartIndex - (payNotional() ? 0.0 : 1.0));
return new CouponFixed(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), fixedRate);
}
}
double referenceEndTime = 0.0;
double referenceStartTime = 0.0;
referenceEndTime = TimeCalculator.getTimeBetween(date, _referenceEndDate);
referenceStartTime = TimeCalculator.getTimeBetween(date, _referenceStartDate);
final ZonedDateTime naturalPaymentEndDate = getPaymentDate().minusMonths(_monthLag - _conventionalMonthLag);
final double naturalPaymentEndTime = TimeCalculator.getTimeBetween(date, naturalPaymentEndDate);
final ZonedDateTime naturalPaymentstartDate = naturalPaymentEndDate.minusMonths(12);
final double naturalPaymentStartTime = TimeCalculator.getTimeBetween(date, naturalPaymentstartDate);
return new CouponInflationYearOnYearMonthly(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), getPriceIndex(), referenceStartTime, naturalPaymentStartTime,
referenceEndTime, naturalPaymentEndTime, _payNotional);
}
示例3: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CapFloorInflationYearOnYearMonthly toDerivative(final ZonedDateTime date) {
ArgumentChecker.notNull(date, "date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "Do not have any fixing data but are asking for a derivative after the payment date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
final double lastKnownFixingTime = TimeCalculator.getTimeBetween(date, _lastKnownFixingDate);
final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
final double referenceStartTime = TimeCalculator.getTimeBetween(date, _referenceStartDate);
final double referenceEndTime = TimeCalculator.getTimeBetween(date, _referenceEndDate);
final ZonedDateTime naturalPaymentEndDate = getPaymentDate().minusMonths(_monthLag - _conventionalMonthLag);
final double naturalPaymentEndTime = TimeCalculator.getTimeBetween(date, naturalPaymentEndDate);
final ZonedDateTime naturalPaymentstartDate = naturalPaymentEndDate.minusMonths(12);
final double naturalPaymentStartTime = TimeCalculator.getTimeBetween(date, naturalPaymentstartDate);
return new CapFloorInflationYearOnYearMonthly(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), getPriceIndex(), lastKnownFixingTime,
referenceStartTime, naturalPaymentStartTime, referenceEndTime, naturalPaymentEndTime, _strike, _isCap);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:CapFloorInflationYearOnYearMonthlyDefinition.java
示例4: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CouponInflationYearOnYearInterpolation toDerivative(final ZonedDateTime date) {
ArgumentChecker.notNull(date, "date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "Do not have any fixing data but are asking for a derivative after the payment date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
final double[] referenceStartTime = new double[2];
referenceStartTime[0] = TimeCalculator.getTimeBetween(date, getReferenceStartDates()[0]);
referenceStartTime[1] = TimeCalculator.getTimeBetween(date, getReferenceStartDates()[1]);
final double[] referenceEndTime = new double[2];
referenceEndTime[0] = TimeCalculator.getTimeBetween(date, getReferenceEndDate()[0]);
referenceEndTime[1] = TimeCalculator.getTimeBetween(date, getReferenceEndDate()[1]);
final ZonedDateTime naturalPaymentEndDate = getPaymentDate().minusMonths(_monthLag - _conventionalMonthLag);
final double naturalPaymentEndTime = TimeCalculator.getTimeBetween(date, naturalPaymentEndDate);
final ZonedDateTime naturalPaymentstartDate = naturalPaymentEndDate.minusMonths(12);
final double naturalPaymentStartTime = TimeCalculator.getTimeBetween(date, naturalPaymentstartDate);
return new CouponInflationYearOnYearInterpolation(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), getPriceIndex(), referenceStartTime, naturalPaymentStartTime,
referenceEndTime,
naturalPaymentEndTime, _payNotional, _weightStart, _weightEnd);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:CouponInflationYearOnYearInterpolationDefinition.java
示例5: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CouponInflationYearOnYearInterpolationWithMargin toDerivative(final ZonedDateTime date) {
ArgumentChecker.notNull(date, "date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "Do not have any fixing data but are asking for a derivative after the payment date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
final double[] referenceStartTime = new double[2];
referenceStartTime[0] = TimeCalculator.getTimeBetween(date, getReferenceStartDate()[0]);
referenceStartTime[1] = TimeCalculator.getTimeBetween(date, getReferenceStartDate()[1]);
final double[] referenceEndTime = new double[2];
referenceEndTime[0] = TimeCalculator.getTimeBetween(date, getReferenceEndDate()[0]);
referenceEndTime[1] = TimeCalculator.getTimeBetween(date, getReferenceEndDate()[1]);
final ZonedDateTime naturalPaymentEndDate = getPaymentDate().minusMonths(_monthLag - _conventionalMonthLag);
final double naturalPaymentEndTime = TimeCalculator.getTimeBetween(date, naturalPaymentEndDate);
final ZonedDateTime naturalPaymentstartDate = naturalPaymentEndDate.minusMonths(12);
final double naturalPaymentStartTime = TimeCalculator.getTimeBetween(date, naturalPaymentstartDate);
return new CouponInflationYearOnYearInterpolationWithMargin(_factor, getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), getPriceIndex(), referenceStartTime,
naturalPaymentStartTime,
referenceEndTime,
naturalPaymentEndTime, _payNotional, _weightStart, _weightEnd);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:CouponInflationYearOnYearInterpolationWithMarginDefinition.java
示例6: 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
示例7: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Coupon toDerivative(final ZonedDateTime date, final DoubleTimeSeries<ZonedDateTime> priceIndexTimeSeries) {
ArgumentChecker.notNull(date, "date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
final LocalDate dayConversion = date.toLocalDate();
final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
final LocalDate dayFixing = getReferenceEndDate()[1].toLocalDate();
if (dayConversion.isAfter(dayFixing)) {
final Double fixedEndIndex1 = priceIndexTimeSeries.getValue(_referenceEndDate[1]);
if (fixedEndIndex1 != null) {
final Double fixedEndIndex0 = priceIndexTimeSeries.getValue(_referenceEndDate[0]);
final Double fixedEndIndex = getWeightEnd() * fixedEndIndex0 + (1 - getWeightEnd()) * fixedEndIndex1;
final Double fixedStartIndex1 = priceIndexTimeSeries.getValue(_referenceStartDate[1]);
final Double fixedStartIndex0 = priceIndexTimeSeries.getValue(_referenceStartDate[0]);
final Double fixedStartIndex = getWeightStart() * fixedStartIndex0 + (1 - getWeightStart()) * fixedStartIndex1;
final Double fixedRate = (fixedEndIndex / fixedStartIndex - 1.0);
return new CouponFixed(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), payOff(fixedRate));
}
}
final double lastKnownFixingTime = TimeCalculator.getTimeBetween(date, _lastKnownFixingDate);
final double[] referenceStartTime = new double[2];
referenceStartTime[0] = TimeCalculator.getTimeBetween(date, _referenceStartDate[0]);
referenceStartTime[1] = TimeCalculator.getTimeBetween(date, _referenceStartDate[1]);
final double[] referenceEndTime = new double[2];
referenceEndTime[0] = TimeCalculator.getTimeBetween(date, _referenceEndDate[0]);
referenceEndTime[1] = TimeCalculator.getTimeBetween(date, _referenceEndDate[1]);
final ZonedDateTime naturalPaymentEndDate = getPaymentDate().minusMonths(_monthLag - _conventionalMonthLag);
final double naturalPaymentEndTime = TimeCalculator.getTimeBetween(date, naturalPaymentEndDate);
final ZonedDateTime naturalPaymentstartDate = naturalPaymentEndDate.minusMonths(12);
final double naturalPaymentStartTime = TimeCalculator.getTimeBetween(date, naturalPaymentstartDate);
return new CapFloorInflationYearOnYearInterpolation(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), getPriceIndex(), lastKnownFixingTime, referenceStartTime,
naturalPaymentStartTime, referenceEndTime, naturalPaymentEndTime, _weightStart, _weightEnd, _strike, _isCap);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:35,代码来源:CapFloorInflationYearOnYearInterpolationDefinition.java
示例8: 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 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 CouponInflationZeroCouponInterpolationDefinition from(final ZonedDateTime accrualStartDate,
final ZonedDateTime paymentDate, final double notional,
final IndexPrice priceIndex, final int conventionalMonthLag, final int monthLag, final boolean payNotional) {
final ZonedDateTime refInterpolatedStartDate = accrualStartDate.minusMonths(monthLag);
final ZonedDateTime[] referenceStartDates = new ZonedDateTime[2];
referenceStartDates[0] = refInterpolatedStartDate.with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0);
referenceStartDates[1] = referenceStartDates[0].plusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0);
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, referenceEndDates, payNotional);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:CouponInflationZeroCouponInterpolationDefinition.java
示例9: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CouponInflationYearOnYearMonthlyWithMargin toDerivative(final ZonedDateTime date) {
ArgumentChecker.notNull(date, "date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "Do not have any fixing data but are asking for a derivative after the payment date");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
final double referenceEndTime = TimeCalculator.getTimeBetween(date, getReferenceEndDate());
final double referenceStartTime = TimeCalculator.getTimeBetween(date, getReferenceStartDate());
final ZonedDateTime naturalPaymentEndDate = getPaymentDate().minusMonths(_monthLag - _conventionalMonthLag);
final double naturalPaymentEndTime = TimeCalculator.getTimeBetween(date, naturalPaymentEndDate);
final ZonedDateTime naturalPaymentstartDate = naturalPaymentEndDate.minusMonths(12);
final double naturalPaymentStartTime = TimeCalculator.getTimeBetween(date, naturalPaymentstartDate);
return new CouponInflationYearOnYearMonthlyWithMargin(_factor, getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), getPriceIndex(), referenceStartTime, naturalPaymentStartTime,
referenceEndTime, naturalPaymentEndTime, _payNotional);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:16,代码来源:CouponInflationYearOnYearMonthlyWithMarginDefinition.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());
}
示例11: createMarket1
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* Creates a market with three currencies (EUR, USD, GBP), three Ibor indexes (Euribor3M, Euribor6M, UsdLibor3M) and three inflation (Euro HICP x, UK RPI and US CPI-U).
* The US CPI-U price curve is constructed to have the correct past data (if available in the time series) and a fake 2% inflation for the future.
* No seasonal adjustment is done.
* @param pricingDate The data for which the curve is constructed.
* @return The market.
*/
public static InflationIssuerProviderDiscount createMarket1(final ZonedDateTime pricingDate) {
final InflationIssuerProviderDiscount market = new InflationIssuerProviderDiscount();
market.setCurve(Currency.USD, USD_RATE_DSC);
market.setCurve(Currency.EUR, EUR_DSC);
market.setCurve(Currency.GBP, CURVE_GBP_35);
market.setCurve(Currency.AUD, AUD_DSC);
market.setCurve(USDLIBOR3M, USD_FWD3);
market.setCurve(EURIBOR3M, EUR_FWD3);
market.setCurve(EURIBOR6M, EUR_FWD6);
market.setCurve(AUDBB3M, AUD_FWD3);
market.setCurve(AUDBB6M, AUD_FWD6);
market.setCurve(PRICE_INDEX_EUR, PRICE_INDEX_CURVE_EUR);
market.setCurve(PRICE_INDEX_GBP, PRICE_INDEX_CURVE_GBP);
market.setCurve(ISSUER_UK_GOVT, CURVE_GBP_30);
market.setCurve(ISSUER_US_GOVT, CURVE_USD_30);
final ZonedDateTime spotUs = ScheduleCalculator.getAdjustedDate(pricingDate, SPOT_LAG_US, CALENDAR_USD);
final ZonedDateTime referenceInterpolatedDate = spotUs.minusMonths(MONTH_LAG_US);
final ZonedDateTime[] referenceDate = new ZonedDateTime[2];
referenceDate[0] = referenceInterpolatedDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
referenceDate[1] = referenceDate[0].plusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
final int[] yearUs = new int[] {1, 5, 10, 20, 50 };
final double[] indexValueUs = new double[2 + 2 * yearUs.length];
final double[] timeValueUs = new double[2 + 2 * yearUs.length];
indexValueUs[0] = USCPI_TIME_SERIES.getValue(referenceDate[0]);
indexValueUs[1] = USCPI_TIME_SERIES.getValue(referenceDate[1]);
timeValueUs[0] = TimeCalculator.getTimeBetween(pricingDate, referenceDate[0]);
timeValueUs[1] = TimeCalculator.getTimeBetween(pricingDate, referenceDate[1]);
final ZonedDateTime[] maturityDateUs = new ZonedDateTime[2 * yearUs.length];
// double[] maturityTimeUs = new double[yearUs.length];
for (int loopus = 0; loopus < yearUs.length; loopus++) {
maturityDateUs[2 * loopus] = ScheduleCalculator.getAdjustedDate(referenceDate[0], Period.ofYears(yearUs[loopus]), BUSINESS_DAY_USD, CALENDAR_USD);
maturityDateUs[2 * loopus + 1] = ScheduleCalculator.getAdjustedDate(referenceDate[1], Period.ofYears(yearUs[loopus]), BUSINESS_DAY_USD, CALENDAR_USD);
timeValueUs[2 + 2 * loopus] = TimeCalculator.getTimeBetween(pricingDate, maturityDateUs[2 * loopus]);
timeValueUs[2 + 2 * loopus + 1] = TimeCalculator.getTimeBetween(pricingDate, maturityDateUs[2 * loopus + 1]);
indexValueUs[2 + 2 * loopus] = indexValueUs[0] * Math.pow(1 + 0.02, yearUs[loopus]); // 2% inflation a year.
indexValueUs[2 + 2 * loopus + 1] = indexValueUs[1] * Math.pow(1 + 0.02, yearUs[loopus]); // 2% inflation a year.
}
final InterpolatedDoublesCurve curveUs = InterpolatedDoublesCurve.from(timeValueUs, indexValueUs, new LinearInterpolator1D(), NAME_USD_PRICE_INDEX);
final PriceIndexCurveSimple priceIndexCurveUs = new PriceIndexCurveSimple(curveUs);
market.setCurve(PRICE_INDEX_USD, priceIndexCurveUs);
return market;
}
示例12: from
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* Builder for inflation Year on Yearn based on an inflation lag and index publication. The fixing date is the publication lag after the last reference month. The month lag is the conventional one.
* @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.
* @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 inflation zero-coupon cap/floor.
*/
public static CapFloorInflationYearOnYearMonthlyDefinition from(final ZonedDateTime accrualStartDate, final ZonedDateTime paymentDate, final double notional,
final IndexPrice priceIndex, final int conventionalMonthLag, final ZonedDateTime lastKnownFixingDate, final double strike, final boolean isCap) {
ZonedDateTime referenceStartDate = accrualStartDate.minusMonths(conventionalMonthLag);
ZonedDateTime referenceEndDate = paymentDate.minusMonths(conventionalMonthLag);
referenceStartDate = referenceStartDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
referenceEndDate = referenceEndDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
return new CapFloorInflationYearOnYearMonthlyDefinition(priceIndex.getCurrency(), paymentDate, accrualStartDate, paymentDate, 1.0, notional, priceIndex, lastKnownFixingDate, conventionalMonthLag,
conventionalMonthLag, referenceStartDate, referenceEndDate, strike, isCap);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:CapFloorInflationYearOnYearMonthlyDefinition.java
示例13: from
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* Builder for inflation zero-coupon based on an inflation lag and index publication. The fixing date is the publication lag after the last reference month.
* The end accrual date is the payment date.
* @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 CouponInflationZeroCouponMonthlyGearingDefinition 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) {
ZonedDateTime referenceStartDate = accrualStartDate.minusMonths(monthLag);
ZonedDateTime referenceEndDate = paymentDate.minusMonths(monthLag);
referenceStartDate = referenceStartDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0);
referenceEndDate = referenceEndDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).withHour(0).withMinute(0);
return new CouponInflationZeroCouponMonthlyGearingDefinition(priceIndex.getCurrency(), paymentDate, accrualStartDate, paymentDate, 1.0, notional, priceIndex,
conventionalMonthLag, monthLag, referenceStartDate, indexStartValue, referenceEndDate, payNotional, factor);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:CouponInflationZeroCouponMonthlyGearingDefinition.java