public CashSecurity visitCashNode(final CashNode cashNode) {
final Convention convention = _conventionSource.getConvention(cashNode.getConvention());
if (convention == null) {
throw new OpenGammaRuntimeException("Convention with id " + cashNode.getConvention() + " was null");
}
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 CashSecurity(currency,
depositConvention.getRegionCalendar(),
startDate,
endDate,
dayCount,
_rate,
_amount);
} 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,