Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableCashflow"/> class.
        /// </summary>
        /// <param name="cashflowId">The identifier.</param>
        /// <param name="payerIsBaseParty">The is base party flag.</param>
        /// <param name="modelIdentifier">The _model identifier.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="paymentDate">The payment date.</param>
        /// <param name="paymentType">Type of the payment.</param>
        /// <param name="cashflowType">Type of the cashflow.</param>
        /// <param name="includePaymentDate">if set to <c>true</c> [include payment date].</param>
        /// <param name="paymentCalendar">Type paymentCalendar.</param>
        protected PriceableCashflow
        (
            string cashflowId
            , string modelIdentifier
            , bool payerIsBaseParty
            , Money amount
            , AdjustableOrAdjustedDate paymentDate
            , PaymentType paymentType
            , CashflowType cashflowType
            , bool includePaymentDate
            , IBusinessCalendar paymentCalendar)
        {
            Multiplier = 1.0m;
            var date = AdjustedDateHelper.GetAdjustedDate(paymentCalendar, paymentDate);

            if (date != null)
            {
                PaymentDate = (DateTime)date;
            }

            var containsPaymentDateAdjustments = AdjustableOrAdjustedDateHelper.Contains(paymentDate, ItemsChoiceType.dateAdjustments, out var dateAdjustments);

            if (containsPaymentDateAdjustments && dateAdjustments != null)
            {
                PaymentDateAdjustments = (BusinessDayAdjustments)dateAdjustments;
            }
            PayerIsBaseParty = payerIsBaseParty;
            Id = cashflowId;
            ModelIdentifier               = modelIdentifier;
            PaymentType                   = paymentType;
            PaymentAmount                 = amount;
            ForecastAmount                = amount;
            CashflowType                  = cashflowType;
            PaymentDateIncluded           = includePaymentDate;
            PricingStructureEvolutionType = PricingStructureEvolutionType.ForwardToSpot;
            RiskMaturityDate              = PaymentDate;
            DiscountCurveName             = CurveNameHelpers.GetDiscountCurveName(amount.currency.Value, true);
            if (!PaymentCurrencies.Contains(amount.currency.Value))
            {
                PaymentCurrencies.Add(amount.currency.Value);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="cache"></param>
        /// <param name="nameSpace"></param>
        /// <param name="swaptionFpML"> </param>
        /// <param name="basePartyReference"></param>
        /// <param name="forecastRateInterpolation"></param>
        public InterestRateSwaptionPricer(ILogger logger, ICoreCache cache, String nameSpace,
                                          Swaption swaptionFpML, string basePartyReference, Boolean forecastRateInterpolation)
            : base(logger, cache, nameSpace, swaptionFpML, basePartyReference, forecastRateInterpolation)
        {
            ProductType = ProductTypeSimpleEnum.InterestRateSwaption;
            var underlyingSwap = new InterestRateSwapPricer(logger, cache, nameSpace, null, swaptionFpML.swap, basePartyReference, forecastRateInterpolation);

            Swap = underlyingSwap;
            //Add the currencies for the trade pricer.
            foreach (var ccy in Swap.PaymentCurrencies)
            {
                if (!PaymentCurrencies.Contains(ccy))
                {
                    PaymentCurrencies.Add(ccy);
                }
            }
            if (underlyingSwap.SwapType == SwapType.FixedFloat && underlyingSwap.ProductType == ProductTypeSimpleEnum.InterestRateSwap)
            {
                if (Swap.BasePartyPayingFixed && underlyingSwap.PayLeg.Strike != null)
                {
                    StrikeRate = (decimal)underlyingSwap.PayLeg.Strike;
                    if (!IsBasePartyBuyer)
                    {
                        IsCall = true;
                    }
                }
                if (!Swap.BasePartyPayingFixed && underlyingSwap.ReceiveLeg.Strike != null)//
                {
                    StrikeRate = (decimal)underlyingSwap.ReceiveLeg.Strike;
                    if (IsBasePartyBuyer)
                    {
                        IsCall = true;
                    }
                }
                VolatilitySurfaceName = CurveNameHelpers.GetRateVolatilityMatrixName(swaptionFpML.swap);
            }
            BucketedDates    = new DateTime[] { };
            RiskMaturityDate = Swap.RiskMaturityDate;
        }