Esempio n. 1
0
 /// <summary>
 /// Register price factors.
 /// </summary>
 public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
 {
     factors.Register <DiscountRate>(InterestRateUtils.GetRateId(fDeal.Discount_Rate, fDeal.Currency));
     factors.RegisterInterface <IFxRate>(fDeal.Currency);
     factors.RegisterInterface <IExpectedLoss>(fDeal.Reference_Index);
     factors.RegisterInterface <IRealizedLoss>(fDeal.Reference_Index);
 }
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            IInflationCashflowListDeal deal = (IInflationCashflowListDeal)Deal;

            if (deal.NeedInflationRate())
            {
                factors.RegisterInterface <IInflationRate>(deal.Index);
            }

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

            if (NeedRecoveryRate())
            {
                factors.Register <RecoveryRate>(GetRecoveryRateID());
            }

            if (NeedSurvivalProb())
            {
                factors.RegisterInterface <ISurvivalProb>(GetSurvivalProbID());
            }

            if (!string.IsNullOrEmpty(deal.Repo_Rate))
            {
                factors.RegisterInterface <IInterestRate>(deal.Repo_Rate);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            var deal = (SwaptionDeal)Deal;

            // Get underlying cashflow lists
            SwaptionBaseValuation.SetCashflowLists(errors, deal, ref fFixedCashflowList, ref fFloatCashflowList);

            if (!IsVanillaSwaption())
            {
                Deal.AddToErrors(errors, ErrorLevel.Error, "The Hull White swaption valuation model is for vanilla swaptions only.");
            }

            // Register deal currency
            factors.RegisterInterface <IFxRate>(deal.Currency);

            // Register discount rate
            var    discountId           = InterestRateUtils.GetRateId(deal.Discount_Rate, deal.Currency);
            string discountRateCurrency = DiscountRate.Register(factors, discountId).GetCurrency();

            if (!string.IsNullOrEmpty(discountRateCurrency) && discountRateCurrency != deal.Currency)
            {
                errors.Add(ErrorLevel.Error, "Settlement currency (Currency) and currency of Discount_Rate must be the same");
            }

            // Register forecast rate
            var forecastId           = InterestRateUtils.GetRateId(deal.Forecast_Rate, discountId);
            var forecastRateCurrency = factors.RegisterInterface <IInterestRate>(forecastId).GetCurrency();

            if (forecastRateCurrency != deal.Currency)
            {
                errors.Add(ErrorLevel.Error, "Settlement currency (Currency) and currency of Forecast_Rate must be the same");
            }

            // Register the HW model parameters
            fModelParametersId = string.IsNullOrWhiteSpace(Model_Parameters) ? forecastId : Model_Parameters;

            factors.Register <HullWhite1FactorModelParameters>(fModelParametersId);

            // Check that floating cashflow list is standard enough to be valued by ValueSwap
            if (fFloatCashflowList == null || fFixedCashflowList == null)
            {
                errors.Add(ErrorLevel.Error, "Deal must contain exactly one floating and one fixed leg.");
            }
            else
            {
                var characteristics = fFloatCashflowList.Analyze(factors.BaseDate);
                if (!characteristics.HasSwaplet || characteristics.HasOptionlet ||
                    !characteristics.IsStandardPayoff || characteristics.HasCms || !characteristics.IsStandardLibor ||
                    fFloatCashflowList.Compounding_Method != CompoundingMethod.None || fFixedCashflowList.Compounding == YesNo.Yes)
                {
                    errors.Add(ErrorLevel.Error, "Underlying swap has non-standard floating cashflows.");
                }
            }
        }
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            // Deal must be of IInflationOptionCashflowListDeal type to subscribe to Price Index Volatility.
            factors.RegisterInterface <IPriceIndexVolatility>(((InflationOptionCashflowListDeal)Deal).Price_Index_Volatility);
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Register price factors used in valuation.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            if (!string.IsNullOrEmpty(fForecastCurrency) && fForecastCurrency != fCurrency)
            {
                errors.Add(ErrorLevel.Error, "Settlement currency (Currency) and currency of Forecast_Rate must be the same");
            }

            SetModelParameters(fItems);
            ValidateModels(fItems, errors);

            fItems.RegisterFactors(factors, errors);

            CallableStructuredDeal deal = (CallableStructuredDeal)fDeal;

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

            if (needRating)
            {
                factors.Register <CreditRating>(deal.Issuer);
                factors.Register <RecoveryRate>(InterestRateUtils.GetRateId(deal.Recovery_Rate, deal.Issuer));
            }

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

            CommodityFuture deal = (CommodityFuture)Deal;

            factors.RegisterInterface <ICommodityPrice>(deal.Commodity);
        }
Esempio n. 8
0
        /// <summary>
        /// Register price factors used in valuation.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            var deal = (CFEquityFloatingInterestListDeal)Deal;

            deal.GetDealHelper().RegisterFactors(factors, errors);

            fEquityCurrency = deal.Equity_Currency;
            factors.RegisterInterface <IFxRate>(fEquityCurrency);

            fEquityPayoffCurrency = string.IsNullOrEmpty(deal.Equity_Payoff_Currency) ? fEquityCurrency : deal.Equity_Payoff_Currency;

            if (fEquityPayoffCurrency != fEquityCurrency)
            {
                factors.RegisterInterface <IFxRate>(fEquityPayoffCurrency);
            }

            // Get characteristics
            EquityCashflowListCharacteristics characteristics = deal.Cashflows.Analyze(factors.BaseDate);
            bool quanto = fForecastIsForeign && Quanto_Correction == YesNo.Yes;

            if (characteristics.fHasLibor)
            {
                if ((!characteristics.fIsStandardLibor && Convexity_Correction == YesNo.Yes) || quanto)
                {
                    var forecastRateVol = InterestVolBase.RegisterInterestRateVol(factors, deal.Forecast_Rate_Cap_Volatility, fForecastCurrency);
                    InterestVolBase.Validate(deal, forecastRateVol, ProbabilityDistribution.Lognormal, errors);
                }

                if (!characteristics.fIsStandardLibor && Convexity_Correction == YesNo.Yes)
                {
                    var discountRateVol = InterestVolBase.RegisterInterestRateVol(factors, deal.Discount_Rate_Cap_Volatility, fCurrency);
                    InterestVolBase.Validate(deal, discountRateVol, ProbabilityDistribution.Lognormal, errors);
                }
            }

            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);
            }

            deal.Cashflows.RegisterFactorsValidate(factors.BaseDate, deal.GetEquityPayoffType() == PayoffType.Compo, deal.IsCrossCurrency(), errors);
        }
Esempio n. 9
0
        /// <summary>
        /// Register required price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            var deal = (CalendarSpreadOption)Deal;

            // Register forward price factor - using a reference price.
            var referencePrice = factors.RegisterInterface <IReferencePrice>(deal.Reference_Type);

            // Register volatility price factor based on an explicit user-defined property.
            // Default to Reference Type if Reference Vol Type is not set.
            if (string.IsNullOrEmpty(deal.Reference_Vol_Type))
            {
                factors.Register <ReferenceVol>(deal.Reference_Type);
            }
            else
            {
                factors.Register <ReferenceVol>(deal.Reference_Vol_Type);
            }

            // Register FX rate price factors.
            factors.RegisterInterface <IFxRate>(deal.Currency);
            factors.RegisterInterface <IFxRate>(deal.DealCurrency());
            factors.RegisterInterface <IFxRate>(factors.BaseCcyCode);
            factors.RegisterInterface <IFxRate>(referencePrice.DomesticCurrency());

            // Register correlation price factor.
            factors.Register <ForwardPriceCorrelations>(referencePrice.GetForwardPrice());

            // Register forward price sample price factor for reference prices.
            var sample = factors.Register <ForwardPriceSample>(deal.Sampling_Type);

            if (!string.IsNullOrWhiteSpace(sample.Sampling_Convention))
            {
                sample.Prepare();

                // Validate period 1.
                IEnumerable <ContractPeriod> contractPeriods = deal.GetContractPeriods(deal.Period_Start_1, deal.Period_End_1);
                sample.ValidateRange(contractPeriods, "Set 1 of sample dates", deal, errors);

                // Validate period 2.
                contractPeriods = deal.GetContractPeriods(deal.Period_Start_2, deal.Period_End_2);
                sample.ValidateRange(contractPeriods, "Set 2 of sample dates", deal, errors);
            }

            // Register interest rate price factor to get discount factor.
            factors.RegisterInterface <IInterestRate>(deal.Currency);

            // Register interest rate price factor for discount rate currency.
            if (!string.IsNullOrEmpty(deal.Discount_Rate))
            {
                string discountRateCurrency = factors.RegisterInterface <IInterestRate>(InterestRateUtils.GetRateId(deal.Discount_Rate, deal.Currency)).GetCurrency();
                if (!string.IsNullOrEmpty(discountRateCurrency) && discountRateCurrency != deal.Currency)
                {
                    errors.Add(ErrorLevel.Error, "Currency and currency of Discount_Rate must be the same");
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            CFFixedInterestListDeal deal = (CFFixedInterestListDeal)fDeal;

            // Register factor for translation from rate currency to settlement currency for cashflows with FX reset date
            if (!string.IsNullOrEmpty(deal.Rate_Currency) && deal.Rate_Currency != fCurrency)
            {
                factors.RegisterInterface <IFxRate>(deal.Rate_Currency);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Register price factors.
        /// </summary>
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            base.RegisterFactors(factors, errors);

            var deal = (BondLendingBase)fDeal;

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

            factors.RegisterInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Issuer : deal.Survival_Probability);
        }
Esempio n. 12
0
        // -----------------------------------------------------------------------------
        // Description: Register price factors
        // -----------------------------------------------------------------------------
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            factors.Register <DiscountRate>(InterestRateUtils.GetRateId(fCreditBaseDeal.Discount_Rate, fCreditBaseDeal.Currency));
            factors.RegisterInterface <IFxRate>(fCreditBaseDeal.Currency);
            factors.RegisterInterface <ISurvivalProb>(string.IsNullOrEmpty(fCreditBaseDeal.Survival_Probability) ? fCreditBaseDeal.Name : fCreditBaseDeal.Survival_Probability);

            if (Respect_Default == YesNo.Yes)
            {
                if (fCreditBaseDeal.ProtectionReferenceType() == DealCreditBase.ReferenceType.Single_Name)
                {
                    factors.Register <CreditRating>(fCreditBaseDeal.Name);
                    if (RequiresRecoveryOnDefault())
                    {
                        factors.Register <RecoveryRate>(string.IsNullOrEmpty(fCreditBaseDeal.Recovery_Rate) ? fCreditBaseDeal.Name : fCreditBaseDeal.Recovery_Rate);
                    }
                }
                else
                {
                    factors.Register <IndexCDSPool>(fCreditBaseDeal.Name);
                }
            }
        }
Esempio n. 13
0
        // -----------------------------------------------------------------------------
        // Description: Register price factors
        // -----------------------------------------------------------------------------
        public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
        {
            DealCreditLinkedNote deal = (DealCreditLinkedNote)Deal;

            base.RegisterFactors(factors, errors);

            factors.RegisterInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Name : deal.Survival_Probability);

            if (Respect_Default == YesNo.Yes)
            {
                factors.Register <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? deal.Name : deal.Recovery_Rate);
                factors.Register <CreditRating>(deal.Name);
            }
        }
Esempio n. 14
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));
            }
        }
        /// <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);

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

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

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

            if (RespectDefault())
            {
                factors.Register <RecoveryRate>(InterestRateUtils.GetRateId(deal.GetRecoveryRate(), deal.GetIssuer()));
                factors.Register <CreditRating>(deal.GetIssuer());
            }

            fSettlementOffsetHelper.ValidateHolidayCalendars(factors.CalendarData, errors);
        }
 /// <summary>
 /// Register price factors.
 /// </summary>
 public override void RegisterFactors(PriceFactorList factors, ErrorList errors)
 {
     factors.RegisterInterface <IFxRate>(fDeal.Currency);
 }
Esempio n. 18
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);
        }