Exemplo n.º 1
0
        /// <summary>
        /// Prepare for valuation.
        /// </summary>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);

            SetModelParameters(fItems);

            PreValueDeals(fItems, factors);

            CallableStructuredDeal deal = (CallableStructuredDeal)Deal;

            // Set volatility price factors if they have been registered by model or underlying deals
            InterestVol.TryGet <IInterestRateVol>(factors, deal.Forecast_Rate_Cap_Volatility, fForecastCurrency, out fInterestRateVol);
            InterestVol.TryGet <IInterestYieldVol>(factors, deal.Forecast_Rate_Swaption_Volatility, fForecastCurrency, out fInterestYieldVol);

            bool needRating   = Respect_Default == YesNo.Yes && !string.IsNullOrEmpty(deal.Issuer);
            bool needSurvival = Use_Survival_Probability == YesNo.Yes && !string.IsNullOrEmpty(deal.Issuer);

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

            if (needSurvival)
            {
                fSurvivalProb = factors.GetInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Issuer : deal.Survival_Probability);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prepare for valuation anything that is dependent upon the scenario.
        /// </summary>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);
            BondFutureOption deal = (BondFutureOption)Deal;

            fInterestYieldVol = InterestVolBase.GetYieldVol(factors, deal.Yield_Volatility, fCurrency);

            var bfb = (BondFuturesBasis)fFuturesBasis;

            GenerateCTD(factors.BaseDate, 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;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Prepare for valuation anything that is dependent upon the scenario.
        /// </summary>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);

            CallableBondForward deal = (CallableBondForward)Deal;

            fInterestYieldVol = InterestVolBase.GetYieldVol(factors, deal.Yield_Volatility, fCurrency);

            fNeedsCreditRating = NeedCreditRating();
            fCreditRating      = NeedCreditRating() ? factors.Get <CreditRating>(deal.Issuer)                                                                               : null;
            fRecoveryRate      = NeedRecovery()     ? factors.Get <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? deal.Issuer : deal.Recovery_Rate)               : null;
            fSurvivalProb      = NeedSurvivalProb() ? factors.GetInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Issuer : deal.Survival_Probability) : null;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public CreditValuationParameters(DealCreditBase deal, CreditBaseValuation valuation, PriceFactorList factors, VectorScopedCache.Scope cache)
        {
            DF          = DiscountRate.Get(factors, InterestRateUtils.GetRateId(deal.Discount_Rate, deal.Currency));
            X           = factors.GetInterface <IFxRate>(deal.Currency);
            SP          = factors.GetInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Name : deal.Survival_Probability);
            RR          = null;
            CR          = null;
            DefaultTime = null;
            Weights     = null;
            NamesDefaultedBeforeBaseDate = null;

            if (valuation.Respect_Default == YesNo.Yes)
            {
                List <string> names = new List <string>();
                if (deal.ProtectionReferenceType() == DealCreditBase.ReferenceType.Single_Name)
                {
                    names.Add(deal.Name);
                    Weights = new double[] { 1.0 };
                }
                else
                {
                    IndexCDSPool indexCds = factors.Get <IndexCDSPool>(deal.Name);
                    Weights = new double[indexCds.Names.Count];
                    for (int i = 0; i < indexCds.Names.Count; ++i)
                    {
                        names.Add(indexCds.Names[i].Name);
                        Weights[i] = indexCds.Names[i].Weight;
                    }
                }

                if (valuation.RequiresRecoveryOnDefault())
                {
                    RR = new RecoveryRate[names.Count];
                    for (int i = 0; i < names.Count; ++i)
                    {
                        RR[i] = factors.Get <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? names[i] : deal.Recovery_Rate);
                    }
                }

                CR = new CreditRating[names.Count];
                NamesDefaultedBeforeBaseDate = new bool[names.Count];
                DefaultTime = new Vector[names.Count];
                for (int i = 0; i < names.Count; ++i)
                {
                    DefaultTime[i] = cache.Get();
                    CR[i]          = factors.Get <CreditRating>(names[i]);
                    NamesDefaultedBeforeBaseDate[i] = CreditRating.DefaultedBeforeBaseDate(CR[i], factors.BaseDate);
                    CR[i].DefaultTime(DefaultTime[i]);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Prepare for valuation anything that is dependent upon the scenario.
        /// </summary>
        /// <param name="factors">Price factors.</param>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);

            BondOptionDeal deal = (BondOptionDeal)Deal;

            bool needRating   = Respect_Default == YesNo.Yes && !string.IsNullOrEmpty(deal.Issuer);
            bool needSurvival = Use_Survival_Probability == YesNo.Yes && !string.IsNullOrEmpty(deal.Issuer);
            bool needRecovery = needRating;

            fCreditRating = needRating ? factors.Get <CreditRating>(deal.Issuer) : null;
            fRecoveryRate = needRecovery ? factors.Get <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? deal.Issuer : deal.Recovery_Rate) : null;
            fSurvivalProb = needSurvival ? factors.GetInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Issuer : deal.Survival_Probability) : null;
        }
        /// <summary>
        /// Prepare for valuation anything that is dependent upon the scenario.
        /// </summary>
        /// <param name="factors">Price factors.</param>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);

            IInflationCashflowListDeal deal = (IInflationCashflowListDeal)Deal;

            fIsDefaultNever  = !NeedCreditRating();
            fCreditRating    = NeedCreditRating()                      ? factors.Get <CreditRating>(deal.Issuer)                       : null;
            fRecoveryRate    = NeedRecoveryRate()                      ? factors.Get <RecoveryRate>(GetRecoveryRateID())               : null;
            fSurvivalProb    = NeedSurvivalProb()                      ? factors.GetInterface <ISurvivalProb>(GetSurvivalProbID())     : null;
            fInflationRate   = !string.IsNullOrEmpty(deal.Index)       ? factors.GetInterface <IInflationRate>(deal.Index)             : null;
            fRepoRate        = !string.IsNullOrEmpty(deal.Repo_Rate)   ? factors.GetInterface <IInterestRate>(deal.Repo_Rate)          : fDiscountRate;
            fIndexVolatility = deal is InflationOptionCashflowListDeal?factors.GetInterface <IPriceIndexVolatility>(GetPriceIndexVolatility()) : null;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Create option pricer and other preparation.
        /// </summary>
        protected override InterestRateOptionPricer CreateOptionPricer(PriceFactorList factors)
        {
            CallableStructuredDeal  deal           = (CallableStructuredDeal)fDeal;
            LinearGaussMarkovFactor lgmPriceFactor = factors.Get <LinearGaussMarkovFactor>(fModelParametersId);

            return(new LinearGaussMarkovOptionPricer(deal.Option_Type, fExercises, fItems, fDiscountRate, fForecastRate, fInterestRateVol, fInterestYieldVol, fSurvivalProb, factors.NumScenarios, lgmPriceFactor, Driver_Space_Points, Standard_Deviations, Integration_Points));
        }
Exemplo n.º 8
0
        public PriceFactorList Factors; // temporary expedient

        /// <summary>
        /// Constructor.
        /// </summary>
        public CDOBottomUpValuationParameters(DealCDO deal, CDOValuationBottomUp valuation, PriceFactorList factors)
            : base(deal, factors)
        {
            Factors = factors;

            IndexCDO = factors.Get <IndexCDO>(deal.Reference_Index);
            IndexCDO.SetPricer(new CDOPricer(valuation.Number_Of_Loss_Buckets, valuation.Number_Integration_Steps, valuation.Bucket_Type, !CalcUtils.IsTiny(deal.Spread), deal.Payoff_Is_Digital == YesNo.Yes, deal.Digital_Payoff_Percentage));
        }
Exemplo n.º 9
0
 /// <summary>
 /// Fetch the recovery rate price factor, or null if not applicable.
 /// </summary>
 protected override RecoveryRate GetRecoveryRate(PriceFactorList factors)
 {
     if (Respect_Default == YesNo.Yes)
     {
         var deal = (DealCreditLinkedNote)Deal;
         return(factors.Get <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? deal.Name : deal.Recovery_Rate));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Get price factors.
        /// </summary>
        private void PreValue(PriceFactorList factors)
        {
            var deal = (CalendarSpreadOption)Deal;

            // Get forward price samples.
            fForwardSample = factors.Get <ForwardPriceSample>(deal.Sampling_Type);

            // Get ReferencePrice price factors.
            fReferencePrice1 = factors.GetInterface <IReferencePrice>(deal.Reference_Type);
            fReferencePrice2 = factors.GetInterface <IReferencePrice>(deal.Reference_Type);

            // Get ReferenceVol price factors.
            // Default to Reference Type if Reference Vol Type is not set.
            if (string.IsNullOrEmpty(deal.Reference_Vol_Type))
            {
                fReferenceVol1 = factors.Get <ReferenceVol>(deal.Reference_Type);
                fReferenceVol2 = factors.Get <ReferenceVol>(deal.Reference_Type);
            }
            else
            {
                fReferenceVol1 = factors.Get <ReferenceVol>(deal.Reference_Vol_Type);
                fReferenceVol2 = factors.Get <ReferenceVol>(deal.Reference_Vol_Type);
            }

            // Get correlation price factor based on the ID of the forward price.
            fCorrelations = factors.Get <ForwardPriceCorrelations>(fReferencePrice1.GetForwardPrice());

            // Get FX rate price factors.
            fFxRate            = factors.GetInterface <IFxRate>(deal.Currency);
            fFxPayoffRate      = factors.GetInterface <IFxRate>(deal.DealCurrency());
            fPriceFactorFxRate = factors.GetInterface <IFxRate>(fReferencePrice1.DomesticCurrency());

            // Get discount rate price factor.
            fDiscountRate = factors.GetInterface <IInterestRate>(InterestRateUtils.GetRateId(deal.Discount_Rate, deal.Currency));
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Prepare for valuation anything that is dependent upon the scenario.
        /// </summary>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);

            CFListBaseDeal <TCashflowList> deal = (CFListBaseDeal <TCashflowList>)fDeal;

            if (string.IsNullOrEmpty(fDeal.GetIssuer()))
            {
                return;
            }

            if (UseSurvivalProbability())
            {
                fSurvivalProb = factors.GetInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.GetSurvivalProbability()) ? deal.GetIssuer() : deal.GetSurvivalProbability());
            }

            if (RespectDefault())
            {
                fRecoveryRate = factors.Get <RecoveryRate>(InterestRateUtils.GetRateId(deal.GetRecoveryRate(), deal.GetIssuer()));
                fCreditRating = factors.Get <CreditRating>(deal.GetIssuer());
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Prepare for valuation anything that is dependent upon the scenario.
        /// </summary>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);

            var deal = (BondRepoBase)fDeal;

            if (string.IsNullOrEmpty(deal.Issuer))
            {
                return;
            }

            fSurvivalProb = factors.GetInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Issuer : deal.Survival_Probability);

            fRecoveryRate = factors.Get <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? deal.Issuer : deal.Recovery_Rate);
        }
Exemplo n.º 14
0
        /// <inheritdoc />
        public void PreValue(PriceFactorList factors)
        {
            var deal = (SwaptionDeal)Deal;

            var discountId = InterestRateUtils.GetRateId(deal.Discount_Rate, deal.Currency);
            var forecastId = InterestRateUtils.GetRateId(deal.Forecast_Rate, discountId);

            fModelParameters = factors.Get <HullWhite1FactorModelParameters>(fModelParametersId);

            fFxRate       = factors.GetInterface <IFxRate>(deal.Currency);
            fDiscountRate = DiscountRate.Get(factors, discountId);
            fForecastRate = factors.GetInterface <IInterestRate>(forecastId);

            fQuadrature = new Lazy <GaussHermiteNormalQuadrature>(() => new GaussHermiteNormalQuadrature(30));
        }
Exemplo n.º 15
0
        /// <inheritdoc />
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);

            fModelParameters = factors.Get <HullWhite1FactorModelParameters>(fModelParametersId);
        }
        /// <summary>
        /// Prepare for valuation.
        /// </summary>
        public override void PreValue(PriceFactorList factors)
        {
            base.PreValue(factors);

            CFGeneralInterestSpreadListDeal deal = (CFGeneralInterestSpreadListDeal)Deal;

            // Get spread flow characteristics
            SpreadCashflowListCharacteristics spreadCashflowCharacteristics = fCashflows.ValuationPriceFactorDependencies(factors.BaseDate, fCurrency, fForecastCurrency, fForecast2Currency);

            // vols for first forecast rate
            if (spreadCashflowCharacteristics.NeedForecast1YieldVol)
            {
                fForecast1YieldVol = InterestVolBase.GetYieldVol(factors, deal.Forecast_Rate1_Swaption_Volatility, fForecastCurrency);
            }

            if (spreadCashflowCharacteristics.NeedForecast1RateVol)
            {
                fForecast1RateVol = InterestVolBase.GetRateVol(factors, deal.Forecast_Rate1_Cap_Volatility, fForecastCurrency);
            }

            // vols for second forecast rate
            if (spreadCashflowCharacteristics.NeedForecast2YieldVol)
            {
                fForecast2YieldVol = InterestVolBase.GetYieldVol(factors, deal.Forecast_Rate2_Swaption_Volatility, fForecast2Currency);
            }

            if (spreadCashflowCharacteristics.NeedForecast2RateVol)
            {
                fForecast2RateVol = InterestVolBase.GetRateVol(factors, deal.Forecast_Rate2_Cap_Volatility, fForecast2Currency);
            }

            // vols for discount rate
            if (spreadCashflowCharacteristics.NeedDiscountYieldVol)
            {
                fDiscountYieldVol = InterestVolBase.GetYieldVol(factors, deal.Discount_Rate_Swaption_Volatility, fCurrency);
            }

            if (spreadCashflowCharacteristics.NeedDiscountRateVol)
            {
                fDiscountRateVol = InterestVolBase.GetRateVol(factors, deal.Discount_Rate_Cap_Volatility, fCurrency);
            }

            bool convexity = spreadCashflowCharacteristics.NeedDiscountYieldVol || spreadCashflowCharacteristics.NeedDiscountRateVol;

            if (fForecastCurrency != fCurrency)
            {
                if (Quanto_Correction == YesNo.Yes)
                {
                    // fx vol, fx/ir correl and forecast/discount correl
                    fFx1Vol             = FXVolHelper.Get(factors, fForecastCurrency, fCurrency);
                    fForecast1Fx1Correl = CorrelationHelper.Get(factors, typeof(InterestRate), fForecastCurrency, null, typeof(FxRate), fForecastCurrency, fCurrency);
                }

                if (convexity)
                {
                    fForecast1DiscountCorrel = CorrelationHelper.Get(factors, typeof(InterestRate), fCurrency, null, typeof(InterestRate), fForecastCurrency, null);
                }
            }

            if (fForecast2Currency != fCurrency)
            {
                if (Quanto_Correction == YesNo.Yes)
                {
                    // fx vol, fx/ir correl and forecast/discount correl
                    fFx2Vol             = FXVolHelper.Get(factors, fForecast2Currency, fCurrency);
                    fForecast2Fx2Correl = CorrelationHelper.Get(factors, typeof(InterestRate), fForecast2Currency, null, typeof(FxRate), fForecast2Currency, fCurrency);
                }

                if (convexity)
                {
                    fForecast2DiscountCorrel = CorrelationHelper.Get(factors, typeof(InterestRate), fCurrency, null, typeof(InterestRate), fForecast2Currency, null);
                }
            }

            if (spreadCashflowCharacteristics.NeedForecast1Forecast2Correlation)
            {
                if (fForecastCurrency == fForecast2Currency)
                {
                    // correl between forecast rates in same currency
                    fForecast1Forecast2Correls = factors.Get <CMSRateCorrelations>(fForecastCurrency);
                }
                else
                {
                    fForecast1Forecast2Correl = CorrelationHelper.Get(factors, typeof(InterestRate), fForecastCurrency, null, typeof(InterestRate), fForecast2Currency, null);
                }
            }
        }
Exemplo n.º 17
0
        /// <inheritdoc />
        protected override void GetFuturesPriceFactor(PriceFactorList factors)
        {
            BondFutureOption deal = (BondFutureOption)fDeal;

            fFuturesBasis = factors.Get <BondFuturesBasis>(FutureBase.GetFactorID(deal.Contract, deal.Settlement_Date));
        }
Exemplo n.º 18
0
 /// <summary>
 /// Fetch the credit rating price factor, or null if not applicable.
 /// </summary>
 protected override CreditRating GetCreditRating(PriceFactorList factors)
 {
     return((Respect_Default == YesNo.Yes) ? factors.Get <CreditRating>(((DealCreditLinkedNote)Deal).Name) : null);
 }