示例#1
0
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            BondOptionDeal deal = (BondOptionDeal)Deal;

            InterestVolBase.RegisterInterestYieldVol(factors, deal.Yield_Volatility, fCurrency);

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

            if (needRating)
            {
                factors.Register <CreditRating>(deal.Issuer);
            }

            if (needRecovery)
            {
                factors.Register <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? deal.Issuer : deal.Recovery_Rate);
            }

            if (needSurvival)
            {
                factors.RegisterInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Issuer : deal.Survival_Probability);
            }
        }
示例#2
0
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            BondFutureOption deal = (BondFutureOption)Deal;

            base.RegisterFactors(factors, errors);
            InterestVolBase.RegisterInterestYieldVol(factors, deal.Yield_Volatility, fCurrency);

            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));
            }
        }
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            CallableBondForward deal = (CallableBondForward)Deal;

            InterestVolBase.RegisterInterestYieldVol(factors, deal.Yield_Volatility, deal.Currency);

            if (NeedCreditRating())
            {
                factors.Register <CreditRating>(deal.Issuer);
            }

            if (NeedRecovery())
            {
                factors.Register <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? deal.Issuer : deal.Recovery_Rate);
            }

            if (NeedSurvivalProb())
            {
                factors.RegisterInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Issuer : deal.Survival_Probability);
            }
        }
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            CFGeneralInterestSpreadListDeal deal = (CFGeneralInterestSpreadListDeal)Deal;

            // Collect registered volatility price factors to check they have the same distribution type
            var volPriceFactors = new List <IInterestVol>();

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

            // register volatility surfaces for forecast rate1
            if (spreadCashflowCharacteristics.NeedForecast1YieldVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestYieldVol(factors, deal.Forecast_Rate1_Swaption_Volatility, fForecastCurrency));
            }

            if (spreadCashflowCharacteristics.NeedForecast1RateVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestRateVol(factors, deal.Forecast_Rate1_Cap_Volatility, fForecastCurrency));
            }

            // register volatility surfaces for forecast rate2
            if (spreadCashflowCharacteristics.NeedForecast2YieldVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestYieldVol(factors, deal.Forecast_Rate2_Swaption_Volatility, fForecast2Currency));
            }

            if (spreadCashflowCharacteristics.NeedForecast2RateVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestRateVol(factors, deal.Forecast_Rate2_Cap_Volatility, fForecast2Currency));
            }

            // vol surfaces for discount rate
            if (spreadCashflowCharacteristics.NeedDiscountYieldVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestYieldVol(factors, deal.Discount_Rate_Swaption_Volatility, fCurrency));
            }

            if (spreadCashflowCharacteristics.NeedDiscountRateVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestRateVol(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
                    FXVolHelper.Register(factors, fForecastCurrency, fCurrency);
                    CorrelationHelper.Register(factors, typeof(IInterestRate), fForecastCurrency, null, typeof(IFxRate), fForecastCurrency, fCurrency);
                }

                if (convexity)
                {
                    CorrelationHelper.Register(factors, typeof(IInterestRate), fCurrency, null, typeof(IInterestRate), fForecastCurrency, null);
                }
            }

            if (fForecast2Currency != fCurrency)
            {
                if (Quanto_Correction == YesNo.Yes)
                {
                    // fx vol, fx/ir correl and forecast/discount correl
                    FXVolHelper.Register(factors, fForecast2Currency, fCurrency);
                    CorrelationHelper.Register(factors, typeof(IInterestRate), fForecast2Currency, null, typeof(IFxRate), fForecast2Currency, fCurrency);
                }

                if (convexity)
                {
                    CorrelationHelper.Register(factors, typeof(IInterestRate), fCurrency, null, typeof(IInterestRate), fForecast2Currency, null);
                }
            }

            if (spreadCashflowCharacteristics.NeedForecast1Forecast2Correlation)
            {
                if (fForecastCurrency == fForecast2Currency)
                {
                    // correl between forecast rates in same currency
                    factors.Register <CMSRateCorrelations>(fForecastCurrency);
                }
                else
                {
                    CorrelationHelper.Register(factors, typeof(IInterestRate), fForecastCurrency, null, typeof(IInterestRate), fForecast2Currency, null);
                }
            }

            if (volPriceFactors.Select(pf => pf.GetDistributionType()).Distinct().Count() > 1)
            {
                Deal.AddToErrors(errors, "Volatility price factors must have the same distribution type.");
            }

            ValidateUnnecessaryVolatilities(deal, spreadCashflowCharacteristics, errors);
        }
示例#5
0
        /// <summary>
        /// Register price factors used in valuation.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            CFFloatingInterestListDeal deal = (CFFloatingInterestListDeal)Deal;

            // Deal validation specific to CFFloatingInterestListValuation
            foreach (var cashflow in deal.Cashflows)
            {
                if (!cashflow.Resets.Any())
                {
                    continue;
                }

                var lastResetDate = cashflow.Resets.Last().Reset_Date;
                if (cashflow.FX_Reset_Date > 0.0 && cashflow.FX_Reset_Date < lastResetDate)
                {
                    errors.Add(ErrorLevel.Warning, string.Format("Quanto adjustments for cashflow paying on {0} are not supported when the FX reset date {1} is before interest rate reset date {2}", cashflow.Payment_Date, cashflow.FX_Reset_Date, lastResetDate));
                }
            }

            // Get characteristics
            CashflowListCharacteristics characteristics = deal.Cashflows.Analyze(factors.BaseDate);

            bool quanto    = fForecastIsForeign && characteristics.HasQuanto && Quanto_Correction == YesNo.Yes;
            bool convexity = !characteristics.IsStandardLibor && Convexity_Correction == YesNo.Yes;

            var requirements = new VolatilityRequirements(
                characteristics.HasCms,
                characteristics.HasLibor && (characteristics.HasOptionlet || convexity || quanto),
                characteristics.HasCms && convexity,
                characteristics.HasLibor && convexity);

            // Collect registered volatility price factors to check they have the same distribution type
            var volPriceFactors = new List <IInterestVol>();

            // register forecast rate volatility surfaces
            if (requirements.NeedForecastYieldVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestYieldVol(factors, deal.Forecast_Rate_Swaption_Volatility, fForecastCurrency));
            }

            if (requirements.NeedForecastRateVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestRateVol(factors, deal.Forecast_Rate_Cap_Volatility, fForecastCurrency));
            }

            if (requirements.NeedDiscountYieldVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestYieldVol(factors, deal.Discount_Rate_Swaption_Volatility, fCurrency));
            }

            if (requirements.NeedDiscountRateVol)
            {
                volPriceFactors.Add(InterestVolBase.RegisterInterestRateVol(factors, deal.Discount_Rate_Cap_Volatility, fCurrency));
            }

            if (fForecastIsForeign)
            {
                // Register factor for translation from forecast rate currency to settlement currency for cashflows with FX reset date
                if (characteristics.HasFXReset)
                {
                    factors.RegisterInterface <IFxRate>(fForecastCurrency);
                }

                if (quanto)
                {
                    FXVolHelper.Register(factors, fForecastCurrency, fCurrency);
                    CorrelationHelper.Register(factors, typeof(IInterestRate), fForecastCurrency, null, typeof(IFxRate), fForecastCurrency, fCurrency);
                    CorrelationHelper.Register(factors, typeof(IInterestRate), fForecastCurrency, null, typeof(IInterestRate), fCurrency, null);
                }
            }

            if (volPriceFactors.Select(pf => pf.GetDistributionType()).Distinct().Count() > 1)
            {
                deal.AddToErrors(errors, "Volatility price factors must have the same distribution type.");
            }

            ValidateUnnecessaryVolatilities(deal, requirements, errors);
        }