Inheritance: CalibratedModel
 public TreeCallableFixedRateBondEngine(ShortRateModel model, TimeGrid timeGrid,
                                        Handle <YieldTermStructure> termStructure)
     : base(model, timeGrid)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
 public LatticeShortRateModelEngine(ShortRateModel model,
                                    int timeSteps)
     : base(model)
 {
     timeSteps_ = timeSteps;
     Utils.QL_REQUIRE(timeSteps > 0, () => "timeSteps must be positive, " + timeSteps + " not allowed");
 }
Exemple #3
0
 public TreeVanillaSwapEngine(ShortRateModel model,
                              TimeGrid timeGrid,
                              Handle <YieldTermStructure> termStructure)
     : base(model, timeGrid)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
Exemple #4
0
 public TreeSwaptionEngine(ShortRateModel model,
                           int timeSteps,
                           Handle <YieldTermStructure> termStructure)
     : base(model, timeSteps)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
 public LatticeShortRateModelEngine(ShortRateModel model,
                                    TimeGrid timeGrid)
     : base(model)
 {
     timeGrid_  = new TimeGrid(timeGrid.Last(), timeGrid.size() - 1 /*timeGrid.dt(1) - timeGrid.dt(0)*/);
     timeGrid_  = timeGrid;
     timeSteps_ = 0;
     lattice_   = this.model_.link.tree(timeGrid);
 }
 public LatticeShortRateModelEngine(ShortRateModel model,
                                    int timeSteps)
     : base(model)
 {
     timeSteps_ = timeSteps;
     if (!(timeSteps > 0))
     {
         throw new ArgumentException("timeSteps must be positive, " + timeSteps +
                                     " not allowed");
     }
 }
        static void CalibrateModel(ShortRateModel model,
                            List<CalibrationHelper> helpers)
        {
            if (model == null) throw new ArgumentNullException("model");
            var om = new LevenbergMarquardt();
            model.calibrate(helpers, om,
                             new EndCriteria(400, 100, 1.0e-8, 1.0e-8, 1.0e-8), new Constraint(),
                                    new List<double>());

            // Output the implied Black volatilities
            for (int i = 0; i < NumRows; i++)
            {
                int j = NumCols - i - 1; // 1x5, 2x4, 3x3, 4x2, 5x1
                int k = i * NumCols + j;
                double npv = helpers[i].modelValue();
                double implied = helpers[i].impliedVolatility(npv, 1e-4,
                                                                   1000, 0.05, 0.50);
                double diff = implied - SwaptionVols[k];
                Console.WriteLine("{0}x{1}: model {2:0.00000 %}, market {3:0.00000 %}, diff {4:0.00000 %} ",
                                    i + 1, SwapLenghts[j], implied, SwaptionVols[k], diff);
            }
        }
Exemple #8
0
 public TreeSwaptionEngine(ShortRateModel model,
                           TimeGrid timeGrid)
     : this(model, timeGrid, new Handle <YieldTermStructure>())
 {
 }
Exemple #9
0
 /*! \name Constructors
  *  \note the term structure is only needed when the short-rate
  *        model cannot provide one itself.
  */
 //@{
 public TreeSwaptionEngine(ShortRateModel model,
                           int timeSteps)
     : this(model, timeSteps, new Handle <YieldTermStructure>())
 {
 }