public DVPLI.EstimationResult Estimate(List <object> data, DVPLI.IEstimationSettings settings = null, DVPLI.IController controller = null, Dictionary <string, object> properties = null)
        {
            DVPLI.InterestRateMarketData irmd = data[0] as DVPLI.InterestRateMarketData;

            //Date today = new Date(15, Month.February, 2002);
            //Date settlement = new Date(19, Month.February, 2002);
            Settings.setEvaluationDate(irmd.Date);



            Handle <YieldTermStructure> termStructure = new Handle <YieldTermStructure>(new Utilities.ZeroRateFunction(irmd.Date, irmd.ZRMarketDates, irmd.ZRMarket));

            //termStructure.link
            HullWhite model = new HullWhite(termStructure);


            IborIndex index = new Euribor6M(termStructure);

            IPricingEngine engine = new JamshidianSwaptionEngine(model);

            List <CalibrationHelper> swaptions = new List <CalibrationHelper>();

            for (int i = 0; i < irmd.SwapDates.Length; i++)
            {
                for (int j = 0; j < irmd.SwapDuration.Length; j++)
                {
                    Quote             vol    = new SimpleQuote(irmd.SwaptionsVolatility[j, i]);
                    CalibrationHelper helper =
                        new SwaptionHelper(new Period((int)irmd.SwapDates[i], TimeUnit.Years),
                                           new Period((int)irmd.SwapDuration[j], TimeUnit.Years),
                                           new Handle <Quote>(vol),
                                           index,
                                           new Period(1, TimeUnit.Years),
                                           new Thirty360(),
                                           new Actual360(),
                                           termStructure,
                                           false);
                    helper.setPricingEngine(engine);
                    swaptions.Add(helper);
                }
            }

            // Set up the optimization problem
            LevenbergMarquardt optimizationMethod = new LevenbergMarquardt(1.0e-8, 1.0e-8, 1.0e-8);
            EndCriteria        endCriteria        = new EndCriteria(10000, 100, 1e-6, 1e-8, 1e-8);

            //Optimize
            model.calibrate(swaptions, optimizationMethod, endCriteria, new Constraint(), new List <double>());
            EndCriteria.Type ecType = model.endCriteria();


            Vector xMinCalculated = model.parameters();
            double yMinCalculated = model.value(xMinCalculated, swaptions);
            Vector xMinExpected   = new Vector(2);

            double yMinExpected = model.value(xMinExpected, swaptions);

            DVPLI.EstimationResult r = new DVPLI.EstimationResult(new string[] { "Alpha", "Sigma" }, new double[] { xMinCalculated[0], xMinCalculated[1] });
            return(r);
        }
 public DVPLI.EstimateRequirement[] GetRequirements(DVPLI.IEstimationSettings settings, DVPLI.EstimateQuery query)
 {
     return(new DVPLI.EstimateRequirement[] { new DVPLI.EstimateRequirement(typeof(DVPLI.InterestRateMarketData)) });
 }