public AnalyticCapFloorEngine(IAffineModel model,
                               Handle <YieldTermStructure> termStructure)
     : base(model)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
Ejemplo n.º 2
0
        public LocalVolCurve(Handle <BlackVarianceCurve> curve)
            : base(curve.link.businessDayConvention(), curve.link.dayCounter())
        {
            blackVarianceCurve_ = curve;

            blackVarianceCurve_.registerWith(update);
        }
Ejemplo n.º 3
0
 public LfmSwaptionEngine(LiborForwardModel model,
                          Handle <YieldTermStructure> discountCurve)
     : base(model)
 {
     discountCurve_ = discountCurve;
     discountCurve_.registerWith(update);
 }
Ejemplo n.º 4
0
 public TreeCallableFixedRateBondEngine(ShortRateModel model, TimeGrid timeGrid,
                                        Handle <YieldTermStructure> termStructure)
     : base(model, timeGrid)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
Ejemplo n.º 5
0
        public RendistatoCalculator(RendistatoBasket basket, Euribor euriborIndex, Handle <YieldTermStructure> discountCurve)
        {
            basket_            = basket;
            euriborIndex_      = euriborIndex;
            discountCurve_     = discountCurve;
            yields_            = new InitializedList <double>(basket_.size(), 0.05);
            durations_         = new List <double>(basket_.size());
            nSwaps_            = 15; // TODO: generalize number of swaps and their lenghts
            swaps_             = new List <VanillaSwap>(nSwaps_);
            swapLenghts_       = new List <double>(nSwaps_);
            swapBondDurations_ = new InitializedList <double?>(nSwaps_, null);
            swapBondYields_    = new InitializedList <double?>(nSwaps_, 0.05);
            swapRates_         = new InitializedList <double?>(nSwaps_, null);

            basket_.registerWith(update);
            euriborIndex_.registerWith(update);
            discountCurve_.registerWith(update);

            double dummyRate = 0.05;

            for (int i = 0; i < nSwaps_; ++i)
            {
                swapLenghts_[i] = (i + 1);
                swaps_[i]       = new MakeVanillaSwap(new Period((int)swapLenghts_[i], TimeUnit.Years),
                                                      euriborIndex_, dummyRate, new Period(1, TimeUnit.Days))
                                  .withDiscountingTermStructure(discountCurve_);
            }
        }
Ejemplo n.º 6
0
        public G2(Handle <YieldTermStructure> termStructure,
                  double a,
                  double sigma,
                  double b,
                  double eta,
                  double rho)
            : base(5)
        {
            //TermStructureConsistentModel = termStructure;

            /* regroupement car plant!!
             * *a_ = arguments_[0];
             * sigma_ = arguments_[1];
             * b_ = arguments_[2];
             * eta_ = arguments_[3];
             * rho_ = arguments_[4];*/

            termStructure_ = termStructure;
            a_             = arguments_[0] = new ConstantParameter(a, new PositiveConstraint());
            sigma_         = arguments_[1] = new ConstantParameter(sigma, new PositiveConstraint());
            b_             = arguments_[2] = new ConstantParameter(b, new PositiveConstraint());
            eta_           = arguments_[3] = new ConstantParameter(eta, new PositiveConstraint());
            rho_           = arguments_[4] = new ConstantParameter(rho, new BoundaryConstraint(-1.0, 1.0));

            generateArguments();
            termStructure.registerWith(update);
        }
Ejemplo n.º 7
0
        public DerivedQuote(Handle <Quote> element, Func <double, double> f)
        {
            element_ = element;
            f_       = f;

            element_.registerWith(this.update);
        }
Ejemplo n.º 8
0
 /*! \note the term structure is only needed when the short-rate
  *       model cannot provide one itself.
  */
 public JamshidianSwaptionEngine(OneFactorAffineModel model,
                                 Handle <YieldTermStructure> termStructure)
     : base(model)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
Ejemplo n.º 9
0
 public void setMeanReversion(Handle <Quote> meanReversion)
 {
     meanReversion_.unregisterWith(update);
     meanReversion_ = meanReversion;
     meanReversion_.registerWith(update);
     update();
 }
Ejemplo n.º 10
0
 public BlackCapFloorEngine(Handle <YieldTermStructure> termStructure,
                            double vol, DayCounter dc)
 {
     termStructure_ = termStructure;
     volatility_    = new Handle <OptionletVolatilityStructure>(new ConstantOptionletVolatility(0, new NullCalendar(), BusinessDayConvention.Following, vol, dc));
     termStructure_.registerWith(update);// registerWith(termStructure_);
 }
Ejemplo n.º 11
0
        public InterpolatedPiecewiseZeroSpreadedTermStructure(Handle <YieldTermStructure> h,
                                                              List <Handle <Quote> > spreads,
                                                              List <Date> dates,
                                                              Compounding compounding = Compounding.Continuous,
                                                              Frequency frequency     = Frequency.NoFrequency,
                                                              DayCounter dc           = default(DayCounter),
                                                              Interpolator factory    = default(Interpolator))
        {
            originalCurve_ = h;
            spreads_       = spreads;
            dates_         = dates;
            times_         = new InitializedList <double>(dates.Count);
            spreadValues_  = new InitializedList <double>(dates.Count);
            compounding_   = compounding;
            frequency_     = frequency;
            dc_            = dc ?? new DayCounter();
            factory_       = factory ?? new Interpolator();

            Utils.QL_REQUIRE(!spreads_.empty(), () => "no spreads given");
            Utils.QL_REQUIRE(spreads_.Count == dates_.Count, () => "spread and date vector have different sizes");

            originalCurve_.registerWith(update);

            for (int i = 0; i < spreads_.Count; i++)
            {
                spreads_[i].registerWith(update);
            }

            if (!originalCurve_.empty())
            {
                updateInterpolation();
            }
        }
Ejemplo n.º 12
0
        protected ConvertibleBond(Exercise exercise,
                                  double conversionRatio,
                                  DividendSchedule dividends,
                                  CallabilitySchedule callability,
                                  Handle <Quote> creditSpread,
                                  Date issueDate,
                                  int settlementDays,
                                  Schedule schedule,
                                  double redemption)
            : base(settlementDays, schedule.calendar(), issueDate)
        {
            conversionRatio_ = conversionRatio;
            callability_     = callability;
            dividends_       = dividends;
            creditSpread_    = creditSpread;

            maturityDate_ = schedule.endDate();

            if (!callability.empty())
            {
                Utils.QL_REQUIRE(callability.Last().date() <= maturityDate_,
                                 "last callability date ("
                                 + callability.Last().date()
                                 + ") later than maturity ("
                                 + maturityDate_.ToShortDateString() + ")");
            }

            creditSpread.registerWith(update);
        }
Ejemplo n.º 13
0
 public BMAIndex(Handle <YieldTermStructure> h)
     : base("BMA", new Period(1, TimeUnit.Weeks), 1, new USDCurrency(),
            new UnitedStates(UnitedStates.Market.NYSE), new ActualActual(ActualActual.Convention.ISDA))
 {
     termStructure_ = h;
     h.registerWith(update);
 }
Ejemplo n.º 14
0
        protected SwaptionVolatilityCube(Handle <SwaptionVolatilityStructure> atmVol,
                                         List <Period> optionTenors,
                                         List <Period> swapTenors,
                                         List <double> strikeSpreads,
                                         List <List <Handle <Quote> > > volSpreads,
                                         SwapIndex swapIndexBase,
                                         SwapIndex shortSwapIndexBase,
                                         bool vegaWeightedSmileFit)
            : base(optionTenors, swapTenors, 0, atmVol.link.calendar(), atmVol.link.businessDayConvention(),
                   atmVol.link.dayCounter())
        {
            atmVol_               = atmVol;
            nStrikes_             = strikeSpreads.Count;
            strikeSpreads_        = strikeSpreads;
            localStrikes_         = new InitializedList <double>(nStrikes_);
            localSmile_           = new List <double>(nStrikes_);
            volSpreads_           = volSpreads;
            swapIndexBase_        = swapIndexBase;
            shortSwapIndexBase_   = shortSwapIndexBase;
            vegaWeightedSmileFit_ = vegaWeightedSmileFit;

            Utils.QL_REQUIRE(!atmVol_.empty(), () => "atm vol handle not linked to anything");
            for (int i = 1; i < nStrikes_; ++i)
            {
                Utils.QL_REQUIRE(strikeSpreads_[i - 1] < strikeSpreads_[i], () =>
                                 "non increasing strike spreads: " + i + " is " + strikeSpreads_[i - 1] + ", " +
                                 (i + 1) + " is " + strikeSpreads_[i]);
            }

            Utils.QL_REQUIRE(!volSpreads_.empty(), () => "empty vol spreads matrix");

            Utils.QL_REQUIRE(nOptionTenors_ * nSwapTenors_ == volSpreads_.Count, () =>
                             "mismatch between number of option tenors * swap tenors (" +
                             nOptionTenors_ * nSwapTenors_ + ") and number of rows (" +
                             volSpreads_.Count + ")");

            for (int i = 0; i < volSpreads_.Count; i++)
            {
                Utils.QL_REQUIRE(nStrikes_ == volSpreads_[i].Count, () =>
                                 "mismatch between number of strikes (" + nStrikes_ +
                                 ") and number of columns (" + volSpreads_[i].Count +
                                 ") in the " + (i + 1) + " row");
            }

            atmVol_.registerWith(update);
            atmVol_.link.enableExtrapolation();

            swapIndexBase_.registerWith(update);
            shortSwapIndexBase_.registerWith(update);

            Utils.QL_REQUIRE(shortSwapIndexBase_.tenor() < swapIndexBase_.tenor(), () =>
                             "short index tenor (" + shortSwapIndexBase_.tenor() +
                             ") is not less than index tenor (" +
                             swapIndexBase_.tenor() + ")");

            registerWithVolatilitySpread();
            Settings.registerWith(update);
            evaluationDate_ = Settings.evaluationDate();
        }
Ejemplo n.º 15
0
 public BlackCapFloorEngine(Handle <YieldTermStructure> discountCurve, double vol,
                            DayCounter dc = null, double displacement = 0.0)
 {
     discountCurve_ = discountCurve;
     vol_           = new Handle <OptionletVolatilityStructure>(new ConstantOptionletVolatility(0, new NullCalendar(), BusinessDayConvention.Following, vol, dc ?? new Actual365Fixed()));
     displacement_  = displacement;
     discountCurve_.registerWith(update);// registerWith(termStructure_);
 }
Ejemplo n.º 16
0
 //! volatility is the quoted fwd yield volatility, not price vol
 public BlackCallableFixedRateBondEngine(Handle <CallableBondVolatilityStructure> yieldVolStructure,
                                         Handle <YieldTermStructure> discountCurve)
 {
     volatility_    = yieldVolStructure;
     discountCurve_ = discountCurve;
     volatility_.registerWith(update);
     discountCurve_.registerWith(update);
 }
Ejemplo n.º 17
0
        public SpreadedSmileSection(SmileSection underlyingSection, Handle <Quote> spread)
        {
            underlyingSection_ = underlyingSection;
            spread_            = spread;

            underlyingSection_.registerWith(update);
            spread_.registerWith(update);
        }
Ejemplo n.º 18
0
 public BlackSwaptionEngine(Handle <YieldTermStructure> discountCurve,
                            Handle <SwaptionVolatilityStructure> vol)
 {
     termStructure_ = discountCurve;
     volatility_    = vol;
     termStructure_.registerWith(update);
     volatility_.registerWith(update);
 }
Ejemplo n.º 19
0
        public YoYInflationCapFloorEngine(YoYInflationIndex index, Handle <YoYOptionletVolatilitySurface> vol)
        {
            index_      = index;
            volatility_ = vol;

            index_.registerWith(update);
            volatility_.registerWith(update);
        }
Ejemplo n.º 20
0
 public IborCouponPricer(Handle <OptionletVolatilityStructure> v)
 {
     capletVol_ = v;
     if (!capletVol_.empty())
     {
         capletVol_.registerWith(update);
     }
 }
Ejemplo n.º 21
0
 public CallableBondConstantVolatility(int settlementDays, Calendar calendar, Handle <Quote> volatility, DayCounter dayCounter)
     : base(settlementDays, calendar)
 {
     volatility_   = volatility;
     dayCounter_   = dayCounter;
     maxBondTenor_ = new Period(100, TimeUnit.Years);
     volatility_.registerWith(update);
 }
Ejemplo n.º 22
0
 public TreeVanillaSwapEngine(ShortRateModel model,
                              TimeGrid timeGrid,
                              Handle <YieldTermStructure> termStructure)
     : base(model, timeGrid)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
Ejemplo n.º 23
0
        public ForwardSpreadedTermStructure(Handle <YieldTermStructure> h, Handle <Quote> spread)
        {
            originalCurve_ = h;
            spread_        = spread;

            originalCurve_.registerWith(update);
            spread_.registerWith(update);
        }
        public LocalConstantVol(Date referenceDate, Handle <Quote> volatility, DayCounter dc)
            : base(referenceDate)
        {
            volatility_ = volatility;
            dayCounter_ = dc;

            volatility_.registerWith(update);
        }
        public LocalConstantVol(int settlementDays, Calendar calendar, Handle <Quote> volatility, DayCounter dayCounter)
            : base(settlementDays, calendar)
        {
            volatility_ = volatility;
            dayCounter_ = dayCounter;

            volatility_.registerWith(update);
        }
        //! floating reference date, floating market data
        public ConstantOptionletVolatility(int settlementDays, Calendar cal, BusinessDayConvention bdc,
                                           Handle <Quote> vol, DayCounter dc)
            : base(settlementDays, cal, bdc, dc)
        {
            volatility_ = vol;

            volatility_.registerWith(update);
        }
Ejemplo n.º 27
0
 public TreeSwaptionEngine(ShortRateModel model,
                           int timeSteps,
                           Handle <YieldTermStructure> termStructure)
     : base(model, timeSteps)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
        //! fixed reference date, floating market data
        public ConstantOptionletVolatility(Date referenceDate, Calendar cal, BusinessDayConvention bdc,
                                           Handle <Quote> vol, DayCounter dc)
            : base(referenceDate, cal, bdc, dc)
        {
            volatility_ = vol;

            volatility_.registerWith(update);
        }
Ejemplo n.º 29
0
 public SpreadedOptionletVolatility(Handle <OptionletVolatilityStructure> baseVol, Handle <Quote> spread)
 {
     baseVol_ = baseVol;
     spread_  = spread;
     enableExtrapolation(baseVol.link.allowsExtrapolation());
     baseVol_.registerWith(update);
     spread_.registerWith(update);
 }
Ejemplo n.º 30
0
 public CallableBondConstantVolatility(Date referenceDate, Handle <Quote> volatility, DayCounter dayCounter)
     : base(referenceDate)
 {
     volatility_   = volatility;
     dayCounter_   = dayCounter;
     maxBondTenor_ = new Period(100, TimeUnit.Years);
     volatility_.registerWith(update);
 }