/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(RateCalculationSwapLeg beanToCopy) { this.payReceive = beanToCopy.getPayReceive(); this.accrualSchedule = beanToCopy.getAccrualSchedule(); this.paymentSchedule = beanToCopy.getPaymentSchedule(); this.notionalSchedule = beanToCopy.getNotionalSchedule(); this.calculation = beanToCopy.getCalculation(); }
private static SwapTrade parseVariableRates(SwapTrade trade, List<CsvRow> variableRows) { ImmutableList.Builder<ValueStep> stepBuilder = ImmutableList.builder(); for (CsvRow row : variableRows) { LocalDate date = LoaderUtils.parseDate(row.getValue(START_DATE_FIELD)); row.findValue(FIXED_RATE_FIELD) .map(str -> LoaderUtils.parseDoublePercent(str)) .ifPresent(fixedRate -> stepBuilder.add(ValueStep.of(date, ValueAdjustment.ofReplace(fixedRate)))); } ImmutableList<ValueStep> varRates = stepBuilder.build(); if (varRates.isEmpty()) { return trade; } // adjust the trade, inserting the variable rates ImmutableList.Builder<SwapLeg> legBuilder = ImmutableList.builder(); for (SwapLeg swapLeg : trade.getProduct().getLegs()) { RateCalculationSwapLeg leg = (RateCalculationSwapLeg) swapLeg; if (leg.getCalculation() instanceof FixedRateCalculation) { FixedRateCalculation baseCalc = (FixedRateCalculation) leg.getCalculation(); FixedRateCalculation calc = baseCalc.toBuilder() .rate(ValueSchedule.of(baseCalc.getRate().getInitialValue(), varRates)) .build(); legBuilder.add(leg.toBuilder().calculation(calc).build()); } else { legBuilder.add(leg); } } return replaceLegs(trade, legBuilder.build()); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -885469925: // payReceive return ((RateCalculationSwapLeg) bean).getPayReceive(); case 304659814: // accrualSchedule return ((RateCalculationSwapLeg) bean).getAccrualSchedule(); case -1499086147: // paymentSchedule return ((RateCalculationSwapLeg) bean).getPaymentSchedule(); case 1447860727: // notionalSchedule return ((RateCalculationSwapLeg) bean).getNotionalSchedule(); case -934682935: // calculation return ((RateCalculationSwapLeg) bean).getCalculation(); case 3575610: // type return ((RateCalculationSwapLeg) bean).getType(); case -2129778896: // startDate return ((RateCalculationSwapLeg) bean).getStartDate(); case -1607727319: // endDate return ((RateCalculationSwapLeg) bean).getEndDate(); case 575402001: // currency return ((RateCalculationSwapLeg) bean).getCurrency(); } return super.propertyGet(bean, propertyName, quiet); }
private String legSummary(SwapLeg leg) { if (leg instanceof RateCalculationSwapLeg) { RateCalculationSwapLeg rcLeg = (RateCalculationSwapLeg) leg; RateCalculation calculation = rcLeg.getCalculation(); if (calculation instanceof FixedRateCalculation) { FixedRateCalculation calc = (FixedRateCalculation) calculation;
assertEquals(test.getPaymentSchedule(), paymentSchedule); assertEquals(test.getNotionalSchedule(), notionalSchedule); assertEquals(test.getCalculation(), rateCalc);
assertEquals(test.getPaymentSchedule(), paymentSchedule); assertEquals(test.getNotionalSchedule(), notionalSchedule); assertEquals(test.getCalculation(), rateCalc);
assertEquals(test.getPaymentSchedule(), paymentSchedule); assertEquals(test.getNotionalSchedule(), notionalSchedule); assertEquals(test.getCalculation(), rateCalc);
assertEquals(test.getPaymentSchedule(), paymentSchedule); assertEquals(test.getNotionalSchedule(), notionalSchedule); assertEquals(test.getCalculation(), rateCalc); RateAccrualPeriod rap0 = RateAccrualPeriod.builder() .startDate(bda.adjust(DATE_14_06_09, REF_DATA))