// variable fixed rate
        private static SwapTrade parseVariableRates(SwapTrade trade, IList <CsvRow> variableRows)
        {
            ImmutableList.Builder <ValueStep> stepBuilder = ImmutableList.builder();
            foreach (CsvRow row in 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.Empty)
            {
                return(trade);
            }
            // adjust the trade, inserting the variable rates
            ImmutableList.Builder <SwapLeg> legBuilder = ImmutableList.builder();
            foreach (SwapLeg swapLeg in trade.Product.Legs)
            {
                RateCalculationSwapLeg leg = (RateCalculationSwapLeg)swapLeg;
                if (leg.Calculation is FixedRateCalculation)
                {
                    FixedRateCalculation baseCalc = (FixedRateCalculation)leg.Calculation;
                    FixedRateCalculation calc     = baseCalc.toBuilder().rate(ValueSchedule.of(baseCalc.Rate.InitialValue, varRates)).build();
                    legBuilder.add(leg.toBuilder().calculation(calc).build());
                }
                else
                {
                    legBuilder.add(leg);
                }
            }
            return(replaceLegs(trade, legBuilder.build()));
        }