}
private SwapSecurity getOISSwap(final InterpolatedYieldCurveSpecification spec, final FixedIncomeStripWithIdentifier strip, final SnapshotDataBundle marketValues) {
final FixedIncomeStrip underlyingStrip = strip.getStrip();
final ExternalId swapIdentifier = strip.getSecurity();
final ConventionBundle swapConvention = _conventionBundleSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, spec.getCurrency().getCode() + "_OIS_SWAP"));
if (swapConvention == null) {
throw new OpenGammaRuntimeException("Could not get convention for id " + ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, spec.getCurrency().getCode() + "_OIS_SWAP"));
}
if (!swapConvention.getSwapFloatingLegFrequency().equals(swapConvention.getSwapFixedLegFrequency())) {
throw new OpenGammaRuntimeException("Payment frequencies for the fixed and floating legs did not match");
}
final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, swapConvention.getSwapFloatingLegRegion());
final ZonedDateTime curveDate = spec.getCurveDate().atStartOfDay(ZoneOffset.UTC);
final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(curveDate, swapConvention.getSwapFixedLegSettlementDays(), calendar);
final ZonedDateTime maturityDate = spotDate.plus(strip.getMaturity().getPeriod());
final String counterparty = "";
final Double rate = marketValues.getDataPoint(swapIdentifier);
if (rate == null) {
throw new OpenGammaRuntimeException("rate was null on " + strip + " from " + spec);
}
Frequency floatingFrequency;
final ExternalId floatingReferenceRateId;
if (underlyingStrip.getResetTenor() != null) {
final Period resetTenor = underlyingStrip.getResetTenor().getPeriod();
floatingFrequency = PeriodFrequency.of(resetTenor);
final IndexType indexType = underlyingStrip.getIndexType();
floatingReferenceRateId = ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, indexType + "_" + resetTenor.toString());
} else {
floatingFrequency = swapConvention.getSwapFloatingLegFrequency();
if (floatingFrequency == null) {
throw new OpenGammaRuntimeException("Could not get floating leg frequency from convention");
}
floatingReferenceRateId = swapConvention.getSwapFloatingLegInitialRate();
if (floatingReferenceRateId == null) {
throw new OpenGammaRuntimeException("Could not get floating reference rate from convention");
}
}
final FloatingInterestRateLeg oisLeg = new FloatingInterestRateLeg(swapConvention.getSwapFloatingLegDayCount(), floatingFrequency,
swapConvention.getSwapFloatingLegRegion(), swapConvention.getSwapFloatingLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, floatingReferenceRateId,
FloatingRateType.OIS);
final FixedInterestRateLeg fixedLeg = new FixedInterestRateLeg(swapConvention.getSwapFixedLegDayCount(), swapConvention.getSwapFixedLegFrequency(), swapConvention.getSwapFixedLegRegion(),
swapConvention.getSwapFixedLegBusinessDayConvention(), new InterestRateNotional(spec.getCurrency(), 1), false, rate);
final SwapSecurity swap = new SwapSecurity(curveDate, spotDate, maturityDate, counterparty, oisLeg, fixedLeg);
swap.setExternalIdBundle(ExternalIdBundle.of(swapIdentifier));
return swap;
}