本文整理汇总了Java中org.threeten.bp.ZonedDateTime.toLocalDate方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.toLocalDate方法的具体用法?Java ZonedDateTime.toLocalDate怎么用?Java ZonedDateTime.toLocalDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.toLocalDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSurfaceFromVolatilityQuote
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/** Build a volatility surface based on Expiry, T, and Strike, K. T is in measured in our standard OG-Analytic years */
private static VolatilitySurfaceData<Double, Double> getSurfaceFromVolatilityQuote(final VolatilitySurfaceData<Object, Object> optionVolatilities, final ZonedDateTime now,
final Calendar calendar) {
final Map<Pair<Double, Double>, Double> volatilityValues = new HashMap<>();
final DoubleArrayList tList = new DoubleArrayList();
final DoubleArrayList kList = new DoubleArrayList();
final LocalDate today = now.toLocalDate();
final Object[] xs = optionVolatilities.getXs();
for (final Object xObj : optionVolatilities.getXs()) {
final Number x = (Number) xObj;
final Double t = FutureOptionUtils.getIRFutureOptionTtm(x.intValue(), today, calendar);
final Object[] ys = optionVolatilities.getYs();
for (final Object yObj : ys) {
final Double y = (Double) yObj;
final Double volatility = optionVolatilities.getVolatility(x, y);
if (volatility != null) {
tList.add(t);
kList.add(y / 100.);
volatilityValues.put(Pairs.of(t, y / 100.), volatility / 100); // TODO Normalisation, could this be done elsewhere?
}
}
}
return new VolatilitySurfaceData<>(optionVolatilities.getDefinitionName(), optionVolatilities.getSpecificationName(), optionVolatilities.getTarget(), tList.toArray(new Double[0]),
kList.toArray(new Double[0]), volatilityValues);
}
示例2: buildSecurityDirectory
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* @param buid
* @param tickMsgList
* @return
*/
private File buildSecurityDirectory(String buid, long receivedTS) {
Instant instant = Instant.ofEpochMilli(receivedTS);
ZonedDateTime dateTime = ZonedDateTime.ofInstant(instant, ZoneOffset.UTC);
LocalDate today = dateTime.toLocalDate();
StringBuilder buf = new StringBuilder();
buf.append(_rootDir).append(File.separator);
buf.append(buid).append(File.separator).append(today.getYear()).append(File.separator);
int month = today.getMonthValue();
if (month < 10) {
buf.append("0").append(month);
} else {
buf.append(month);
}
buf.append(File.separator);
int dayOfMonth = today.getDayOfMonth();
if (dayOfMonth < 10) {
buf.append("0").append(dayOfMonth);
} else {
buf.append(dayOfMonth);
}
buf.append(File.separator);
return new File(buf.toString());
}
示例3: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Annuity<? extends Coupon> toDerivative(final ZonedDateTime valZdt, final DoubleTimeSeries<ZonedDateTime> indexFixingTS) {
ArgumentChecker.notNull(valZdt, "date");
ArgumentChecker.notNull(indexFixingTS, "index fixing time series");
final List<Coupon> resultList = new ArrayList<>();
final CouponONSpreadDefinition[] payments = getPayments();
final ZonedDateTime valZdtInPaymentZone = valZdt.withZoneSameInstant(payments[0].getPaymentDate().getZone());
final LocalDate valDate = valZdtInPaymentZone.toLocalDate();
for (int loopcoupon = 0; loopcoupon < payments.length; loopcoupon++) {
if (!valDate.isAfter(payments[loopcoupon].getPaymentDate().toLocalDate())) {
resultList.add(payments[loopcoupon].toDerivative(valZdt, indexFixingTS));
}
}
return new Annuity<>(resultList.toArray(new Coupon[resultList.size()]));
}
示例4: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CouponIborAverageFixingDates toDerivative(final ZonedDateTime date) {
ArgumentChecker.notNull(date, "date");
final int nDates = _weight.length;
final LocalDate dayConversion = date.toLocalDate();
ArgumentChecker.isTrue(!dayConversion.isAfter(getPaymentDate().toLocalDate()), "date is after payment date");
ArgumentChecker.isTrue(!dayConversion.isAfter(getFixingDate()[0].toLocalDate()), "Do not have any fixing data but are asking for a derivative at " + date
+ " which is after fixing date " + getFixingDate()[0]);
// Fixing dates are in increasing order; only the first one need to be checked.
final double paymentTime = TimeCalculator.getTimeBetween(date, getPaymentDate());
final double[] fixingTime = new double[nDates];
final double[] fixingPeriodStartTime = new double[nDates];
final double[] fixingPeriodEndTime = new double[nDates];
for (int i = 0; i < nDates; ++i) {
fixingTime[i] = TimeCalculator.getTimeBetween(date, getFixingDate()[i]);
fixingPeriodStartTime[i] = TimeCalculator.getTimeBetween(date, getFixingPeriodStartDate()[i]);
fixingPeriodEndTime[i] = TimeCalculator.getTimeBetween(date, getFixingPeriodEndDate()[i]);
}
return new CouponIborAverageFixingDates(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(),
getIndex(), fixingTime, getWeight(), fixingPeriodStartTime, fixingPeriodEndTime, getFixingPeriodAccrualFactor(), 0);
}
示例5: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Coupon toDerivative(final ZonedDateTime date, final DoubleTimeSeries<ZonedDateTime> priceIndexTimeSeries) {
ArgumentChecker.notNull(date, "date");
ArgumentChecker.notNull(priceIndexTimeSeries, "price index time series");
ArgumentChecker.isTrue(!date.isAfter(getPaymentDate()), "date is after payment date");
final Double fixedStartIndex = priceIndexTimeSeries.getValue(getReferenceStartDate());
ArgumentChecker.notNull(fixedStartIndex, "first fixing not in the price index time series");
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 fixedRate = (fixedEndIndex / fixedStartIndex - 1.0);
return new CouponFixed(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), payOff(fixedRate));
}
}
final double referenceEndTime = TimeCalculator.getTimeBetween(date, _referenceEndDate);
final double lastKnownFixingTime = TimeCalculator.getTimeBetween(date, getlastKnownFixingDate());
final ZonedDateTime naturalPaymentDate = getPaymentDate().minusMonths(_monthLag - _conventionalMonthLag);
final double naturalPaymentEndTime = TimeCalculator.getTimeBetween(date, naturalPaymentDate);
return new CapFloorInflationZeroCouponMonthly(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), getPriceIndex(), lastKnownFixingTime, fixedStartIndex, referenceEndTime,
naturalPaymentEndTime, _maturity, _strike, _isCap);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:CapFloorInflationZeroCouponMonthlyDefinition.java
示例6: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Annuity<? extends Coupon> toDerivative(final ZonedDateTime valZdt, final DoubleTimeSeries<ZonedDateTime> indexFixingTS) {
ArgumentChecker.notNull(valZdt, "date");
ArgumentChecker.notNull(indexFixingTS, "index fixing time series");
final List<Coupon> resultList = new ArrayList<>();
final CouponONArithmeticAverageDefinition[] payments = getPayments();
final ZonedDateTime valZdtInPaymentZone = valZdt.withZoneSameInstant(payments[0].getPaymentDate().getZone());
final LocalDate valDate = valZdtInPaymentZone.toLocalDate();
for (int loopcoupon = 0; loopcoupon < payments.length; loopcoupon++) {
if (!valDate.isAfter(payments[loopcoupon].getPaymentDate().toLocalDate())) {
resultList.add(payments[loopcoupon].toDerivative(valZdt, indexFixingTS));
}
}
return new Annuity<>(resultList.toArray(new Coupon[resultList.size()]));
}
示例7: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CouponIborFxReset toDerivative(ZonedDateTime dateTime) {
ArgumentChecker.notNull(dateTime, "dateTime");
LocalDate dayConversion = dateTime.toLocalDate();
ArgumentChecker.isTrue(!dayConversion.isAfter(getIborIndexFixingDate().toLocalDate()),
"Do not have any fixing data but are asking for a derivative at " + dateTime +
" which is after ibor index fixing date " + getIborIndexFixingDate());
ArgumentChecker.isTrue(!dayConversion.isAfter(getPaymentDate().toLocalDate()), "date is after payment date");
double paymentTime = TimeCalculator.getTimeBetween(dateTime, getPaymentDate());
double fixingTime = TimeCalculator.getTimeBetween(dateTime, getIborIndexFixingDate());
double fixingPeriodStartTime = TimeCalculator.getTimeBetween(dateTime, getIborIndexFixingPeriodStartDate());
double fixingPeriodEndTime = TimeCalculator.getTimeBetween(dateTime, getIborIndexFixingPeriodEndDate());
double fxFixingTime = TimeCalculator.getTimeBetween(dateTime, _fxFixingDate);
double fxDeliveryTime = TimeCalculator.getTimeBetween(dateTime, _fxDeliveryDate);
return new CouponIborFxReset(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), fixingTime,
getIndex(), fixingPeriodStartTime, fixingPeriodEndTime, getIborIndexFixingPeriodAccrualFactor(), _spread,
getReferenceCurrency(), fxFixingTime, fxDeliveryTime);
}
示例8: 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);
}
示例9: getAccrued
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
private double getAccrued(DayCount dayCount, Calendar calendar, ZonedDateTime valuationDate,
AnnuityDefinition<? extends CouponDefinition> annuity, ZonedDateTimeDoubleTimeSeries indexTimeSeries) {
LocalDate date = valuationDate.toLocalDate();
double res = 0.0;
CouponDefinition[] payments = annuity.getPayments();
for (CouponDefinition payment : payments) {
if (payment.getAccrualStartDate().toLocalDate().isBefore(date) &&
!payment.getPaymentDate().toLocalDate().isBefore(date)) {
double rate;
if (payment instanceof CouponIborDefinition) {
CouponIborDefinition casted = (CouponIborDefinition) payment;
Coupon coupon = casted.toDerivative(valuationDate, indexTimeSeries);
ArgumentChecker.isTrue(coupon instanceof CouponFixed,
"index should be fixed before accrual starts for standard vanilla swap");
CouponFixed couponFixed = (CouponFixed) coupon;
rate = couponFixed.getFixedRate();
} else if (payment instanceof CouponFixedDefinition) {
rate = 1.0;
} else {
throw new IllegalArgumentException("This annuity type is not supported");
}
res += getAccrued(dayCount, calendar, valuationDate, payment) * rate;
}
}
return res;
}
示例10: getDaysBetween
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* Calculates the number of days in between two dates with the date count
* rule specified by the {@code TemporalAdjuster}.
*
* @param startDate the start date-time, not null
* @param includeStart whether to include the start
* @param endDate the end date-time, not null
* @param includeEnd whether to include the end
* @param convention the date adjuster, not null
* @return the number of days between two dates
*/
public static int getDaysBetween(final ZonedDateTime startDate, final boolean includeStart, final ZonedDateTime endDate, final boolean includeEnd, final TemporalAdjuster convention) {
LocalDate date = startDate.toLocalDate();
LocalDate localEndDate = endDate.toLocalDate();
int mult = 1;
if (startDate.isAfter(endDate)) {
date = endDate.toLocalDate();
localEndDate = startDate.toLocalDate();
mult = -1;
}
int result = includeStart ? 1 : 0;
while (!date.with(convention).equals(localEndDate)) {
date = date.with(convention);
result++;
}
return mult * (includeEnd ? result : result - 1);
}
示例11: 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 fixedEndIndex0 = priceIndexTimeSeries.getValue(getReferenceEndDate()[0]);
final Double fixedEndIndex1 = priceIndexTimeSeries.getValue(getReferenceEndDate()[1]);
final Double fixedEndIndex = getWeightEnd() * fixedEndIndex0 + (1 - getWeightEnd()) * fixedEndIndex1;
final Double fixedStartIndex0 = priceIndexTimeSeries.getValue(getReferenceStartDate()[0]);
final Double fixedStartIndex1 = priceIndexTimeSeries.getValue(getReferenceStartDate()[1]);
final Double fixedStartIndex = getWeightStart() * fixedStartIndex0 + (1 - getWeightStart()) * fixedStartIndex1;
final Double fixedRate = (fixedEndIndex / fixedStartIndex - (payNotional() ? 0.0 : 1.0)) + _factor;
return new CouponFixed(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), fixedRate);
}
final double[] referenceEndTime = new double[2];
final double[] referenceStartTime = new double[2];
referenceEndTime[0] = TimeCalculator.getTimeBetween(date, getReferenceEndDate()[0]);
referenceEndTime[1] = TimeCalculator.getTimeBetween(date, getReferenceEndDate()[1]);
referenceStartTime[0] = TimeCalculator.getTimeBetween(date, getReferenceStartDate()[0]);
referenceStartTime[1] = TimeCalculator.getTimeBetween(date, getReferenceStartDate()[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,代码行数:32,代码来源:CouponInflationYearOnYearInterpolationWithMarginDefinition.java
示例12: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Coupon toDerivative(final ZonedDateTime dateTime) {
ArgumentChecker.notNull(dateTime, "date");
final LocalDate dayConversion = dateTime.toLocalDate();
ArgumentChecker.isTrue(!dayConversion.isAfter(getFixingDate().toLocalDate()), "Do not have any fixing data but are asking for a derivative at " + dateTime + " which is after fixing date "
+ getFixingDate());
ArgumentChecker.isTrue(!dayConversion.isAfter(getPaymentDate().toLocalDate()), "date is after payment date");
final double paymentTime = TimeCalculator.getTimeBetween(dateTime, getPaymentDate());
final double fixingTime = TimeCalculator.getTimeBetween(dateTime, getFixingDate());
final double fixingPeriodStartTime = TimeCalculator.getTimeBetween(dateTime, getFixingPeriodStartDate());
final double fixingPeriodEndTime = TimeCalculator.getTimeBetween(dateTime, getFixingPeriodEndDate());
return new CouponIbor(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), fixingTime, getIndex(), fixingPeriodStartTime, fixingPeriodEndTime,
getFixingPeriodAccrualFactor());
}
示例13: visitEquityOptionSecurity
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public InstrumentDefinition<?> visitEquityOptionSecurity(final EquityOptionSecurity security) {
ArgumentChecker.notNull(security, "security");
final boolean isCall = security.getOptionType() == OptionType.CALL;
final double strike = security.getStrike();
final ZonedDateTime expiryDT = security.getExpiry().getExpiry();
final Currency ccy = security.getCurrency();
final double unitNotional = security.getPointValue();
final ExerciseDecisionType exerciseType = security.getExerciseType().accept(ExerciseTypeAnalyticsVisitorAdapter.getInstance());
// TODO We need to know how long after expiry settlement occurs?
// IndexOptions are obviously Cash Settled
final LocalDate settlementDate = expiryDT.toLocalDate(); // FIXME Needs to come from convention
//TODO settlement type needs to come from trade or convention
return new EquityOptionDefinition(isCall, strike, ccy, exerciseType, expiryDT, settlementDate, unitNotional, SettlementType.PHYSICAL);
}
示例14: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public CouponFixedFxReset toDerivative(ZonedDateTime dateTime) {
ArgumentChecker.notNull(dateTime, "date");
LocalDate conversionDate = dateTime.toLocalDate();
LocalDate fixingDate = _fxFixingDate.toLocalDate();
ArgumentChecker.isTrue(!conversionDate.isAfter(fixingDate),
"Do not have any fixing data but are asking for a derivative at {} which is after fixing date {}",
conversionDate, fixingDate);
double paymentTime = TimeCalculator.getTimeBetween(dateTime, getPaymentDate());
double fixingTime = TimeCalculator.getTimeBetween(dateTime, _fxFixingDate);
double deliveryTime = TimeCalculator.getTimeBetween(dateTime, _fxDeliveryDate);
return new CouponFixedFxReset(getCurrency(), paymentTime, getPaymentYearFraction(), getNotional(), _rate,
_referenceCurrency, fixingTime, deliveryTime);
}
示例15: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public SwaptionPhysicalFixedCompoundedONCompounded toDerivative(final ZonedDateTime dateTime) {
ArgumentChecker.notNull(dateTime, "date");
final LocalDate dayConversion = dateTime.toLocalDate();
ArgumentChecker.isTrue(!dayConversion.isAfter(getExpiry().getExpiry().toLocalDate()), "date is after expiry date");
final double expiryTime = TimeCalculator.getTimeBetween(dateTime, _expiry.getExpiry());
final double settlementTime = TimeCalculator.getTimeBetween(dateTime, _settlementDate);
final Swap<CouponFixedAccruedCompounding, CouponONCompounded> underlyingSwap = (Swap<CouponFixedAccruedCompounding, CouponONCompounded>)
_underlyingSwap.toDerivative(dateTime);
return SwaptionPhysicalFixedCompoundedONCompounded.from(expiryTime, underlyingSwap, settlementTime, _isCall, _isLong);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:12,代码来源:SwaptionPhysicalFixedCompoundedONCompoundedDefinition.java