Ejemplo n.º 1
0
        /// <summary>
        /// Prepare for valuation anything that is dependent upon the scenario.
        /// </summary>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);
            BondFuture deal = (BondFuture)Deal;

            var bfb = (BondFuturesBasis)fFuturesBasis;

            GenerateCTD(bfb.CTD_Issue_Date, bfb.CTD_Maturity_Date, bfb.CTD_Coupon_Interval, bfb.CTD_First_Coupon_Date, bfb.CTD_Penultimate_Coupon_Date, bfb.CTD_Day_Count, Deal.GetHolidayCalendar(), bfb.CTD_Coupon_Rate, bfb.CTD_Conversion_Factor);

            if (NeedRating(Respect_Default, deal.Issuer))
            {
                fCreditRating = factors.Get <CreditRating>(deal.Issuer);
                fRecoveryRate = factors.Get <RecoveryRate>(InterestRateUtils.GetRateId(deal.Recovery_Rate, deal.Issuer));
            }
            else
            {
                fCreditRating = null;
                fRecoveryRate = null;
            }

            if (NeedSurvivalProbability(Use_Survival_Probability, deal.Issuer))
            {
                fSurvivalProb = factors.GetInterface <ISurvivalProb>(InterestRateUtils.GetRateId(deal.Survival_Probability, deal.Issuer));
            }
            else
            {
                fSurvivalProb = null;
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        protected override void RegisterFuturesPriceFactor(PriceFactorList factors, ErrorList errors)
        {
            BondFuture deal = (BondFuture)fDeal;

            BondFuturesBasis bfb = factors.Register <BondFuturesBasis>(FutureBase.GetFactorID(deal.Contract, deal.Settlement_Date));

            if (deal.Settlement_Date >= bfb.CTD_Maturity_Date)
            {
                errors.Add(ErrorLevel.Error, "Settlement date must be before cheapest-to-deliver maturity date of the Bond Future Basis price factor.");
            }
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        protected override void GetDefaultTime(Vector defaultTime, PriceFactorList factors)
        {
            BondFuture deal = (BondFuture)Deal;

            if (NeedRating(Respect_Default, deal.Issuer))
            {
                var cr = factors.Get <CreditRating>(deal.Issuer);
                cr.DefaultTime(defaultTime);
                return;
            }

            base.GetDefaultTime(defaultTime, factors);
        }
Ejemplo n.º 4
0
        /// <inheritdoc />
        protected override void ForwardPrice(double baseDate, double valueDate, Vector forwardPrice)
        {
            BondFuture deal = (BondFuture)fDeal;

            double t       = CalcUtils.DaysToYears(valueDate - baseDate);
            double tSettle = CalcUtils.DaysToYears(deal.Settlement_Date - baseDate);

            double accrual, cash;

            PricingFunctions.BondPrice(forwardPrice, out accrual, out cash, baseDate, valueDate, deal.Settlement_Date,
                                       fIssueDate, fMaturityDate, 1.0, fCouponRate, fPayDates,
                                       fAccruals, fDiscountRate, null, null, 0.0, fSurvivalProb, 1.0);

            AdjustForDefault(baseDate, valueDate, forwardPrice, deal.Expiry_Date, Respect_Default == YesNo.Yes && !string.IsNullOrEmpty(deal.Issuer), fUnderlyingIsAlive, fHistoricalRecovery, fDefaultTime, fDiscountRate, fRecoveryRate);

            // If deal.Repo_Rate is null or empty then fRepoRate will default to the DiscountRate
            forwardPrice.Assign(Percentage.OverPercentagePoint * ((forwardPrice / fRepoRate.Get(t, tSettle) - accrual)) / fConversionFactor);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            BondFuture deal = (BondFuture)Deal;

            base.RegisterFactors(factors, errors);

            if (NeedRating(Respect_Default, deal.Issuer))
            {
                factors.Register <CreditRating>(deal.Issuer);

                // register realized recovery rate.
                factors.Register <RecoveryRate>(InterestRateUtils.GetRateId(deal.Recovery_Rate, deal.Issuer));
            }

            if (NeedSurvivalProbability(Use_Survival_Probability, deal.Issuer))
            {
                factors.RegisterInterface <ISurvivalProb>(InterestRateUtils.GetRateId(deal.Survival_Probability, deal.Issuer));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Generate CTD dates and set CTD coupon rate and conversion factor.
        /// </summary>
        protected void GenerateCTD(double issueDate, double maturityDate, double couponInterval, double firstCouponDate, double penultimateCouponDate, DayCount dayCount, IHolidayCalendar calendar, double couponRate, double conversionFactor)
        {
            if (conversionFactor <= 0.0)
            {
                return; // No CTD details or details invalid
            }
            BondFuture deal = (BondFuture)fDeal;

            if (deal.Settlement_Date >= maturityDate)
            {
                throw new AnalyticsException("Settlement date must be before cheapest-to-deliver maturity date.");
            }

            DateGenerationRequest dateGenerationRequest = new DateGenerationRequest
            {
                RequiresPayDates      = true,
                RequiresYearFractions = true,
            };

            DateGenerationParams dateGenerationParams = new DateGenerationParams
            {
                EffectiveDate         = issueDate,
                MaturityDate          = maturityDate,
                CouponPeriod          = couponInterval,
                FirstCouponDate       = firstCouponDate,
                PenultimateCouponDate = penultimateCouponDate,
                AccrualCalendar       = calendar,
                AccrualDayCount       = dayCount
            };

            DateGenerationResults dateGenerationResults = CashflowGeneration.GenerateCashflowDateAndValueLists(dateGenerationRequest, dateGenerationParams);

            fPayDates = dateGenerationResults.PayDates;
            fAccruals = dateGenerationResults.AccrualYearFractions;

            fIssueDate        = issueDate;
            fMaturityDate     = maturityDate;
            fCouponRate       = couponRate;
            fConversionFactor = conversionFactor;
        }
Ejemplo n.º 7
0
        /// <inheritdoc />
        protected override void GetFuturesPriceFactor(PriceFactorList factors)
        {
            BondFuture deal = (BondFuture)fDeal;

            fFuturesBasis = factors.Get <BondFuturesBasis>(FutureBase.GetFactorID(deal.Contract, deal.Settlement_Date));
        }