final double paymentTime = TimeCalculator.getTimeBetween(dateTime, getPaymentDate());
final LocalDate dayFixing = getFixingDate().toLocalDate();
if (dayConversion.equals(dayFixing)) { // The fixing is on the reference date; if known the fixing is used and if not, the floating coupon is created.
final Double fixedRate = indexFixingTimeSeries.getValue(getFixingDate());
if (fixedRate != null) {
return new CouponFixed(getCurrency(), paymentTime, fundingCurveName, getPaymentYearFraction(), getNotional(), _factor * fixedRate + _spread);
}
}
if (dayConversion.isAfter(dayFixing)) { // The fixing is required
final Double fixedRate = indexFixingTimeSeries.getValue(getFixingDate());
if (fixedRate == null) {
throw new OpenGammaRuntimeException("Could not get fixing value for date " + getFixingDate());
}
return new CouponFixed(getCurrency(), paymentTime, fundingCurveName, getPaymentYearFraction(), getNotional(), _factor * fixedRate + _spread);
}
final double fixingTime = TimeCalculator.getTimeBetween(dateTime, getFixingDate());
final double fixingPeriodStartTime = TimeCalculator.getTimeBetween(dateTime, getFixingPeriodStartDate());
final double fixingPeriodEndTime = TimeCalculator.getTimeBetween(dateTime, getFixingPeriodEndDate());
return new CouponIborGearing(getCurrency(), paymentTime, fundingCurveName, getPaymentYearFraction(), getNotional(), fixingTime, getIndex(), fixingPeriodStartTime, fixingPeriodEndTime,