// a summary of the leg private string legSummary(SwapLeg leg) { if (leg is RateCalculationSwapLeg) { RateCalculationSwapLeg rcLeg = (RateCalculationSwapLeg)leg; RateCalculation calculation = rcLeg.Calculation; if (calculation is FixedRateCalculation) { FixedRateCalculation calc = (FixedRateCalculation)calculation; string vary = calc.Rate.Steps.Count > 0 || calc.Rate.StepSequence.Present ? " variable" : ""; return(SummarizerUtils.percent(calc.Rate.InitialValue) + vary); } if (calculation is IborRateCalculation) { IborRateCalculation calc = (IborRateCalculation)calculation; string gearing = calc.Gearing.map(g => " * " + SummarizerUtils.value(g.InitialValue)).orElse(""); string spread = calc.Spread.map(s => " + " + SummarizerUtils.percent(s.InitialValue)).orElse(""); return(calc.Index.Name + gearing + spread); } if (calculation is OvernightRateCalculation) { OvernightRateCalculation calc = (OvernightRateCalculation)calculation; string avg = calc.AccrualMethod == OvernightAccrualMethod.AVERAGED ? " avg" : ""; string gearing = calc.Gearing.map(g => " * " + SummarizerUtils.value(g.InitialValue)).orElse(""); string spread = calc.Spread.map(s => " + " + SummarizerUtils.percent(s.InitialValue)).orElse(""); return(calc.Index.Name + avg + gearing + spread); } if (calculation is InflationRateCalculation) { InflationRateCalculation calc = (InflationRateCalculation)calculation; string gearing = calc.Gearing.map(g => " * " + SummarizerUtils.value(g.InitialValue)).orElse(""); return(calc.Index.Name + gearing); } } if (leg is KnownAmountSwapLeg) { KnownAmountSwapLeg kaLeg = (KnownAmountSwapLeg)leg; string vary = kaLeg.Amount.Steps.Count > 0 || kaLeg.Amount.StepSequence.Present ? " variable" : ""; return(SummarizerUtils.amount(kaLeg.Currency, kaLeg.Amount.InitialValue) + vary); } ImmutableSet <Index> allIndices = leg.allIndices(); return(allIndices.Empty ? "Fixed" : allIndices.ToString()); }