final ConventionBundle fixedLegConvention = getFixedLegConvention(spec, strip, swapIdentifier);
final ZonedDateTime curveDate = spec.getCurveDate().atStartOfDay(ZoneOffset.UTC);
final String counterparty = "";
Calendar calendar;
ExternalId floatingRateId;
FloatingInterestRateLeg iborLeg;
final ExternalId underlyingId = getUnderlyingId(spec, strip);
if (underlyingId == null) {
s_logger.info("Could not get convention for underlying from {}; trying tenor-based convention", strip);
final ExternalId id = ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, spec.getCurrency().getCode() + "_" + months + "M_SWAP");
ConventionBundle floatingLegConvention = _conventionBundleSource.getConventionBundle(id);
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 {
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);