/// <summary> /// Attempts a calibration through <see cref="SwaptionHW1OptimizationProblem"/> /// using swaption matrices. /// </summary> /// <param name="data">The data to be used in order to perform the calibration.</param> /// <param name="settings">The parameter is not used.</param> /// <param name="controller">The controller which may be used to cancel the process.</param> /// <returns>The results of the calibration.</returns> public EstimationResult Estimate(List <object> data, IEstimationSettings settings = null, IController controller = null, Dictionary <string, object> properties = null) { LambdaCalibrationSettings lsettings = (LambdaCalibrationSettings)settings; if (lsettings.Years > lsettings.BondMaturity) { throw new Exception("Bond maturity has to be greater of the historical series time span."); } InterestRateMarketData irmd = data[0] as InterestRateMarketData; List <object> IrmdData = new List <object>(); IrmdData.Add(irmd); CapletEstimator CapEst = new CapletEstimator(); EstimationResult er1 = CapEst.Estimate(IrmdData); DiscountingCurveMarketData[] dcmd = Array.ConvertAll <IMarketData, DiscountingCurveMarketData> ((IMarketData[])data[1], el => (DiscountingCurveMarketData)el); MarketPriceOfRiskCalculator mporc = new MarketPriceOfRiskCalculator(); double lambda = mporc.Calculate(dcmd, lsettings); string[] names = new string[er1.Names.Length + 1]; for (int i = 0; i < er1.Names.Length; i++) { names[i] = er1.Names[i]; } names[er1.Names.Length] = "lambda0"; Vector values = new Vector(er1.Values.Length + 1); values[new Range(0, values.Length - 2)] = (Vector)er1.Values; values[Range.End] = lambda; EstimationResult result = new EstimationResult(names, values); return(result); }
/// <summary> /// Attempts a calibration through <see cref="SwaptionHW1OptimizationProblem"/> /// using swaption matrices. /// </summary> /// <param name="data">The data to be used in order to perform the calibration.</param> /// <param name="settings">The parameter is not used.</param> /// <param name="controller">The controller which may be used to cancel the process.</param> /// <returns>The results of the calibration.</returns> public EstimationResult Estimate(List<object> data, IEstimationSettings settings = null, IController controller = null, Dictionary<string, object> properties = null) { LambdaCalibrationSettings lsettings = (LambdaCalibrationSettings)settings; if (lsettings.Years > lsettings.BondMaturity) throw new Exception("Bond maturity has to be greater of the historical series time span."); InterestRateMarketData irmd = data[0] as InterestRateMarketData; List<object> IrmdData = new List<object>(); IrmdData.Add(irmd); SwaptionHWEstimator shwe = new SwaptionHWEstimator(); EstimationResult er1 = shwe.Estimate(IrmdData); DiscountingCurveMarketData[] dcmd = Array.ConvertAll<IMarketData, DiscountingCurveMarketData> ((IMarketData[])data[1], el => (DiscountingCurveMarketData)el); MarketPriceOfRiskCalculator mporc = new MarketPriceOfRiskCalculator(); double lambda = mporc.Calculate(dcmd, lsettings); string[] names = new string[er1.Names.Length + 1]; for (int i = 0; i < er1.Names.Length; i++) names[i] = er1.Names[i]; names[er1.Names.Length] = "Lambda0"; Vector values = new Vector(er1.Values.Length + 1); values[new Range(0, values.Length - 2)] = (Vector) er1.Values; values[Range.End] = lambda; EstimationResult result = new EstimationResult(names, values); return result; }