floatingRateId = floatingLegConvention.getSwapFloatingLegInitialRate();
if (floatingRateId == null) {
throw new OpenGammaRuntimeException("Could not get floating rate id from convention");
}
iborLeg = new FloatingInterestRateLeg(floatingLegConvention.getSwapFloatingLegDayCount(), floatingLegConvention.getSwapFloatingLegFrequency(),
floatingLegConvention.getSwapFloatingLegRegion(), floatingLegConvention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, floatingRateId,
FloatingRateType.IBOR);
} else {
final ConventionBundle underlyingConvention = _conventionBundleSource.getConventionBundle(underlyingId);
if (underlyingConvention == null || underlyingConvention.getIdentifiers().size() != 1) {
s_logger.info("Could not get unique convention for underlying from {}; trying tenor-based convention", strip);
ConventionBundle floatingLegConvention = _conventionBundleSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME,
spec.getCurrency().getCode() + "_" + months + "M_SWAP"));
if (floatingLegConvention == null) {
floatingLegConvention = _conventionBundleSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME,
spec.getCurrency().getCode() + "_" + months + "_SWAP"));
if (floatingLegConvention == null) {
throw new OpenGammaRuntimeException("Could not get floating leg convention for swap strip " + strip);
}
}
calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, floatingLegConvention.getSwapFloatingLegRegion());
floatingRateId = floatingLegConvention.getSwapFloatingLegInitialRate();
if (floatingRateId == null) {
throw new OpenGammaRuntimeException("Could not get floating rate id from convention");
}
iborLeg = new FloatingInterestRateLeg(floatingLegConvention.getSwapFloatingLegDayCount(), floatingLegConvention.getSwapFloatingLegFrequency(),
floatingLegConvention.getSwapFloatingLegRegion(), floatingLegConvention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, floatingRateId,
FloatingRateType.IBOR);
} else {
calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, underlyingConvention.getRegion());
final ExternalId underlyingTicker = Iterables.getOnlyElement(underlyingConvention.getIdentifiers());
iborLeg = new FloatingInterestRateLeg(underlyingConvention.getDayCount(), PeriodFrequency.of(underlyingConvention.getPeriod()),
underlyingConvention.getRegion(), underlyingConvention.getBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, underlyingTicker,
FloatingRateType.IBOR);
}
}
final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(curveDate, fixedLegConvention.getSwapFixedLegSettlementDays(), calendar);
final ZonedDateTime maturityDate = spotDate.plus(strip.getMaturity().getPeriod());
final FixedInterestRateLeg fixedLeg = new FixedInterestRateLeg(fixedLegConvention.getSwapFixedLegDayCount(), fixedLegConvention.getSwapFixedLegFrequency(),
fixedLegConvention.getSwapFixedLegRegion(), fixedLegConvention.getSwapFixedLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, rate);
final SwapSecurity swap = new SwapSecurity(curveDate, spotDate, maturityDate, counterparty, iborLeg, fixedLeg);
swap.setExternalIdBundle(ExternalIdBundle.of(swapIdentifier));
return swap;
}