}
final Double rate = _marketData.getDataPoint(_dataId);
if (rate == null) {
throw new OpenGammaRuntimeException("Could not get market data for " + _dataId);
}
final Period startPeriod = cashNode.getStartTenor().getPeriod();
final Period maturityPeriod = cashNode.getMaturityTenor().getPeriod();
if (convention instanceof DepositConvention) {
final DepositConvention depositConvention = (DepositConvention) convention;
final Currency currency = depositConvention.getCurrency();
final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, depositConvention.getRegionCalendar());
final BusinessDayConvention businessDayConvention = depositConvention.getBusinessDayConvention();
final boolean isEOM = depositConvention.isIsEOM();
final DayCount dayCount = depositConvention.getDayCount();
final int settlementDays = depositConvention.getSettlementDays();
final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(_valuationTime, settlementDays, calendar);
final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spotDate, startPeriod, businessDayConvention, calendar, isEOM);
final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, maturityPeriod, businessDayConvention, calendar, isEOM);
final double accrualFactor = dayCount.getDayCountFraction(startDate, endDate);
return new CashDefinition(currency, startDate, endDate, 1, rate, accrualFactor);
} else if (convention instanceof IborIndexConvention) {
final IborIndexConvention iborConvention = (IborIndexConvention) convention;
final Currency currency = iborConvention.getCurrency();
final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, iborConvention.getRegionCalendar());
final BusinessDayConvention businessDayConvention = iborConvention.getBusinessDayConvention();
final boolean isEOM = iborConvention.isIsEOM();
final DayCount dayCount = iborConvention.getDayCount();
final int settlementDays = iborConvention.getSettlementDays();
final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(_valuationTime, settlementDays, calendar);
final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spotDate, startPeriod, businessDayConvention, calendar, isEOM);
final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, maturityPeriod, businessDayConvention, calendar, isEOM);
final double accrualFactor = dayCount.getDayCountFraction(startDate, endDate);
final int spotLag = iborConvention.getSettlementDays();
final boolean eom = iborConvention.isIsEOM();
final long months = maturityPeriod.toTotalMonths() - startPeriod.toTotalMonths();
final Period indexTenor = Period.ofMonths((int) months);
final IborIndex iborIndex = new IborIndex(currency, indexTenor, spotLag, dayCount, businessDayConvention, eom, convention.getName());
return new DepositIborDefinition(currency, startDate, endDate, 1, rate, accrualFactor, iborIndex);
} else {
throw new OpenGammaRuntimeException("Could not handle convention of type " + convention.getClass());
}