public static List <object[]> DoCashflowReport(string identifier, PriceableInterestRateStream interestRateStream)
 {
     if (interestRateStream != null)
     {
         var result = new List <object[]>();
         if (interestRateStream.Coupons != null)
         {
             result.AddRange(interestRateStream.Coupons.Select(cashflow => DoCashflowReport(identifier, cashflow)));
         }
         if (interestRateStream.Exchanges != null)
         {
             result.AddRange(interestRateStream.Exchanges.Select(principal => DoCashflowReport(identifier, principal)));
         }
         return(result);
     }
     return(null);
 }
Beispiel #2
0
        protected SwapPricer(ILogger logger, ICoreCache cache, String nameSpace,
                             List <Pair <IBusinessCalendar, IBusinessCalendar> > legCalendars,
                             Swap swapFpML, string basePartyReference,
                             ProductTypeSimpleEnum productType, Boolean forecastRateInterpolation)
        {
            Multiplier = 1.0m;
            if (swapFpML == null)
            {
                return;
            }
            BusinessCentersResolver.ResolveBusinessCenters(swapFpML);
            ForecastRateInterpolation = forecastRateInterpolation;
            //Get the effective date
            AdjustableDate adjustableEffectiveDate = XsdClassesFieldResolver.CalculationPeriodDatesGetEffectiveDate(swapFpML.swapStream[0].calculationPeriodDates);

            EffectiveDate = adjustableEffectiveDate.unadjustedDate.Value;
            //We make the assumption that the termination date is the same for all legs.
            AdjustableDate adjustableTerminationDate = XsdClassesFieldResolver.CalculationPeriodDatesGetTerminationDate(swapFpML.swapStream[0].calculationPeriodDates);
            var            paymentCalendar           = BusinessCenterHelper.ToBusinessCalendar(cache, adjustableTerminationDate.dateAdjustments.businessCenters, nameSpace);

            TerminationDate  = AdjustedDateHelper.ToAdjustedDate(paymentCalendar, adjustableTerminationDate);
            RiskMaturityDate = TerminationDate;
            //EffectiveDate is not set;
            ProductType       = productType;
            PaymentCurrencies = new List <string>();
            //Resolve the payer
            var legs = swapFpML.swapStream.Length;

            if (legs == 0)
            {
                return;
            }
            var flag  = false;
            var index = 0;

            if (legCalendars != null && legCalendars.Count == legs)
            {
                flag = true;
            }
            foreach (var swapStream in swapFpML.swapStream)
            {
                bool payerIsBase = basePartyReference == swapStream.payerPartyReference.href;//TODO add in the calendar functionality.
                //Set the id of the first stream.
                PriceableInterestRateStream leg = flag ? new PriceableInterestRateStream(logger, cache, nameSpace, payerIsBase, swapStream, ForecastRateInterpolation, legCalendars[index].First, legCalendars[index].Second)
                    : new PriceableInterestRateStream(logger, cache, nameSpace, payerIsBase, swapStream, ForecastRateInterpolation, null, null);
                Legs.Add(leg);
                //Add the currencies for the trade pricer.
                if (!PaymentCurrencies.Contains(leg.Currency.Value))
                {
                    PaymentCurrencies.Add(leg.Currency.Value);
                }
                index++;
            }
            if (swapFpML.additionalPayment != null)
            {
                AdditionalPayments = PriceableInstrumentsFactory.CreatePriceablePayments(basePartyReference, swapFpML.additionalPayment, null);
                foreach (var payment in swapFpML.additionalPayment)
                {
                    if (!PaymentCurrencies.Contains(payment.paymentAmount.currency.Value))
                    {
                        PaymentCurrencies.Add(payment.paymentAmount.currency.Value);
                    }
                }
            }
        }