}
final SwapFixedLegConvention fixedLegConvention = _conventionSource.getConvention(SwapFixedLegConvention.class, inflationNode.getFixedLegConvention());
if (fixedLegConvention == null) {
throw new OpenGammaRuntimeException("Convention with id " + inflationNode.getFixedLegConvention() + " was null");
}
final InflationLegConvention inflationLegConvention = _conventionSource.getConvention(InflationLegConvention.class, inflationNode.getInflationLegConvention());
if (inflationLegConvention == null) {
throw new OpenGammaRuntimeException("Convention with id " + inflationNode.getInflationLegConvention() + " was null");
}
final PriceIndexConvention priceIndexConvention = _conventionSource.getConvention(PriceIndexConvention.class, inflationLegConvention.getPriceIndexConvention());
if (priceIndexConvention == null) {
throw new OpenGammaRuntimeException("Convention with id " + inflationLegConvention.getPriceIndexConvention() + " was null");
}
final int settlementDays = fixedLegConvention.getSettlementDays();
final Period tenor = inflationNode.getTenor().getPeriod();
final double notional = 1;
//TODO business day convention and currency are in both conventions - should we enforce that they're the same or use
// different ones for each leg?
final BusinessDayConvention businessDayConvention = fixedLegConvention.getBusinessDayConvention();
final boolean endOfMonth = fixedLegConvention.isIsEOM();
final Currency currency = priceIndexConvention.getCurrency();
final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, priceIndexConvention.getRegion());
final ZoneId zone = _valuationTime.getZone(); //TODO time zone set to midnight UTC
final ZonedDateTime settlementDate = ScheduleCalculator.getAdjustedDate(_valuationTime, settlementDays, calendar).toLocalDate().atStartOfDay(zone);
final ZonedDateTime paymentDate = ScheduleCalculator.getAdjustedDate(settlementDate, tenor, businessDayConvention, calendar, endOfMonth).toLocalDate().atStartOfDay(zone);
final CouponFixedCompoundingDefinition fixedCoupon = CouponFixedCompoundingDefinition.from(currency, settlementDate, paymentDate, notional, tenor.getYears(),
rate);
final HistoricalTimeSeries ts = _timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, priceIndexConvention.getPriceIndexId());
if (ts == null) {
throw new OpenGammaRuntimeException("Could not get price index time series with id " + priceIndexConvention.getPriceIndexId());
}
final LocalDateDoubleTimeSeries localDateTS = ts.getTimeSeries();
final DoubleTimeSeries<ZonedDateTime> priceIndexTimeSeries = convertTimeSeries(zone, localDateTS);
final int conventionalMonthLag = inflationLegConvention.getMonthLag();
final int monthLag = inflationLegConvention.getMonthLag();
final IndexPrice index = new IndexPrice(priceIndexConvention.getName(), currency);
switch (inflationNode.getInflationNodeType()) {
case INTERPOLATED:
{
final CouponInflationZeroCouponInterpolationDefinition inflationCoupon = CouponInflationZeroCouponInterpolationDefinition.from(settlementDate, paymentDate,