Beispiel #1
0
 public void setCorrelation(Handle <Quote> correlation = null)
 {
     correlation_.unregisterWith(update);
     correlation_ = correlation;
     correlation_.registerWith(update);
     update();
 }
 public TreeCallableFixedRateBondEngine(ShortRateModel model, TimeGrid timeGrid,
                                        Handle <YieldTermStructure> termStructure)
     : base(model, timeGrid)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
Beispiel #3
0
        public InterpolatedSmileSection(Date d,
                                        List <double> strikes,
                                        List <Handle <Quote> > stdDevHandles,
                                        Handle <Quote> atmLevel,
                                        DayCounter dc             = null, //Actual365Fixed(),
                                        Interpolator interpolator = default(Interpolator),
                                        Date referenceDate        = null,
                                        VolatilityType type       = VolatilityType.ShiftedLognormal,
                                        double shift = 0.0)
            : base(d, dc ?? new Actual365Fixed(), referenceDate, type, shift)
        {
            exerciseTimeSquareRoot_ = Math.Sqrt(exerciseTime());
            strikes_       = strikes;
            stdDevHandles_ = stdDevHandles;
            atmLevel_      = atmLevel;
            vols_          = new InitializedList <double>(stdDevHandles.Count);

            for (int i = 0; i < stdDevHandles_.Count; ++i)
            {
                stdDevHandles_[i].registerWith(update);
            }
            atmLevel_.registerWith(update);
            // check strikes!!!!!!!!!!!!!!!!!!!!
            if (interpolator == null)
            {
                interpolator = FastActivator <Interpolator> .Create();
            }
            interpolation_ = interpolator.interpolate(strikes_, strikes_.Count, vols_);
        }
Beispiel #4
0
        public DerivedQuote(Handle <Quote> element, Func <double, double> f)
        {
            element_ = element;
            f_       = f;

            element_.registerWith(this.update);
        }
Beispiel #5
0
 public BachelierCapFloorEngine(Handle <YieldTermStructure> discountCurve, Handle <OptionletVolatilityStructure> vol)
 {
     discountCurve_ = discountCurve;
     vol_           = vol;
     discountCurve_.registerWith(update);
     vol_.registerWith(update);
 }
 public AnalyticCapFloorEngine(IAffineModel model,
                               Handle <YieldTermStructure> termStructure)
     : base(model)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
 public void setMeanReversion(Handle <Quote> meanReversion)
 {
     meanReversion_.unregisterWith(update);
     meanReversion_ = meanReversion;
     meanReversion_.registerWith(update);
     update();
 }
        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.Instance.registerWith(update);
            evaluationDate_ = Settings.Instance.evaluationDate();
        }
 //! 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);
 }
 public SpreadedOptionletVolatility(Handle <OptionletVolatilityStructure> baseVol, Handle <Quote> spread)
 {
     baseVol_ = baseVol;
     spread_  = spread;
     enableExtrapolation(baseVol.link.allowsExtrapolation());
     baseVol_.registerWith(update);
     spread_.registerWith(update);
 }
 public TreeSwaptionEngine(ShortRateModel model,
                           int timeSteps,
                           Handle <YieldTermStructure> termStructure)
     : base(model, timeSteps)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
Beispiel #12
0
        public YoYInflationCapFloorEngine(YoYInflationIndex index, Handle <YoYOptionletVolatilitySurface> vol)
        {
            index_      = index;
            volatility_ = vol;

            index_.registerWith(update);
            volatility_.registerWith(update);
        }
        public SpreadedSmileSection(SmileSection underlyingSection, Handle <Quote> spread)
        {
            underlyingSection_ = underlyingSection;
            spread_            = spread;

            underlyingSection_.registerWith(update);
            spread_.registerWith(update);
        }
 public TreeVanillaSwapEngine(ShortRateModel model,
                              TimeGrid timeGrid,
                              Handle <YieldTermStructure> termStructure)
     : base(model, timeGrid)
 {
     termStructure_ = termStructure;
     termStructure_.registerWith(update);
 }
Beispiel #15
0
 public BachelierCapFloorEngine(Handle <YieldTermStructure> discountCurve, double vol, DayCounter dc = null) // new Actual365Fixed()
 {
     discountCurve_ = discountCurve;
     vol_           = new Handle <OptionletVolatilityStructure>(
         new ConstantOptionletVolatility(0, new NullCalendar(), BusinessDayConvention.Following, vol,
                                         dc ?? new Actual365Fixed()));
     discountCurve_.registerWith(update);
 }
        public CompositeQuote(Handle <Quote> element1, Handle <Quote> element2, Func <double, double, double> f)
        {
            element1_ = element1;
            element2_ = element2;
            f_        = f;

            element1_.registerWith(this.update);
            element2_.registerWith(this.update);
        }
 public DiscountingSwapEngine(Handle <YieldTermStructure> discountCurve, bool?includeSettlementDateFlows = null,
                              Date settlementDate = null, Date npvDate = null)
 {
     discountCurve_ = discountCurve;
     discountCurve_.registerWith(update);
     includeSettlementDateFlows_ = includeSettlementDateFlows;
     settlementDate_             = settlementDate;
     npvDate_ = npvDate;
 }
Beispiel #18
0
 public BlackCapFloorEngine(Handle <YieldTermStructure> discountCurve, Handle <OptionletVolatilityStructure> vol,
                            double displacement = 0.0)
 {
     discountCurve_ = discountCurve;
     vol_           = vol;
     displacement_  = displacement;
     discountCurve_.registerWith(update);
     vol_.registerWith(update);
 }
Beispiel #19
0
 public FdmHullWhiteSolver(
     Handle <HullWhite> model,
     FdmSolverDesc solverDesc,
     FdmSchemeDesc schemeDesc = null)
 {
     solverDesc_ = solverDesc;
     schemeDesc_ = schemeDesc ?? new FdmSchemeDesc().Hundsdorfer();
     model_      = model;
     model_.registerWith(update);
 }
Beispiel #20
0
 public void setVolatility(Handle <YoYOptionletVolatilitySurface> vol)
 {
     if (!volatility_.empty())
     {
         volatility_.unregisterWith(update);
     }
     volatility_ = vol;
     volatility_.registerWith(update);
     update();
 }
        //! volatility is the quoted fwd yield volatility, not price vol
        public BlackCallableFixedRateBondEngine(Handle <Quote> fwdYieldVol, Handle <YieldTermStructure> discountCurve)
        {
            volatility_ = new Handle <CallableBondVolatilityStructure>(new CallableBondConstantVolatility(0, new NullCalendar(),
                                                                                                          fwdYieldVol,
                                                                                                          new Actual365Fixed()));
            discountCurve_ = discountCurve;

            volatility_.registerWith(update);
            discountCurve_.registerWith(update);
        }
Beispiel #22
0
 //! floating reference date, floating market data
 public ConstantCapFloorTermVolatility(int settlementDays,
                                       Calendar cal,
                                       BusinessDayConvention bdc,
                                       Handle <Quote> volatility,
                                       DayCounter dc)
     : base(settlementDays, cal, bdc, dc)
 {
     volatility_ = volatility;
     volatility_.registerWith(update);
 }
Beispiel #23
0
 //! fixed reference date, floating market data
 public ConstantCapFloorTermVolatility(Date referenceDate,
                                       Calendar cal,
                                       BusinessDayConvention bdc,
                                       Handle <Quote> volatility,
                                       DayCounter dc)
     : base(referenceDate, cal, bdc, dc)
 {
     volatility_ = volatility;
     volatility_.registerWith(update);
 }
Beispiel #24
0
 public BlackCapFloorEngine(Handle <YieldTermStructure> discountCurve, Handle <Quote> 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);
     vol_.registerWith(update);
 }
Beispiel #25
0
        public HestonBlackVolSurface(Handle <HestonModel> hestonModel)
            : base(hestonModel.link.process().riskFreeRate().link.referenceDate(),
                   new NullCalendar(),
                   BusinessDayConvention.Following,
                   hestonModel.link.process().riskFreeRate().link.dayCounter())
        {
            hestonModel_ = hestonModel;
            integration_ = AnalyticHestonEngine.Integration.gaussLaguerre(164);

            hestonModel_.registerWith(update);
        }
Beispiel #26
0
 public HullWhite(Handle <YieldTermStructure> termStructure,
                  double a, double sigma)
     : base(termStructure.link.forwardRate(0.0, 0.0, Compounding.Continuous, Frequency.NoFrequency).rate(),
            a, 0.0, sigma, 0.0)
 {
     this.termStructure_ = termStructure;
     b_      = arguments_[1] = new NullParameter(); //to change
     lambda_ = arguments_[3] = new NullParameter(); //to change
     generateArguments();
     termStructure.registerWith(update);
 }
Beispiel #27
0
 public BlackKarasinski(Handle <YieldTermStructure> termStructure,
                        double a, double sigma)
     : base(2)
 {
     a_             = arguments_[0];
     sigma_         = arguments_[1];
     a_             = arguments_[0] = new ConstantParameter(a, new PositiveConstraint());
     sigma_         = arguments_[1] = new ConstantParameter(sigma, new PositiveConstraint());
     termStructure_ = new Handle <YieldTermStructure>();
     termStructure_ = termStructure;
     termStructure.registerWith(update);
 }
 public BlackStyleSwaptionEngine(Handle <YieldTermStructure> discountCurve,
                                 Handle <SwaptionVolatilityStructure> volatility,
                                 double?displacement    = 0.0,
                                 CashAnnuityModel model = CashAnnuityModel.DiscountCurve)
 {
     discountCurve_ = discountCurve;
     vol_           = volatility;
     model_         = model;
     displacement_  = displacement;
     discountCurve_.registerWith(update);
     vol_.registerWith(update);
 }
Beispiel #29
0
        // Constructors

        /*! If strike is given in the constructor, can calculate the
         *  NPV of the contract via NPV().
         *
         *  If strike/forward price is desired, it can be obtained via
         *  forwardPrice(). In this case, the strike variable in the
         *  constructor is irrelevant and will be ignored.
         */
        public FixedRateBondForward(Date valueDate, Date maturityDate, Position.Type type, double strike,
                                    int settlementDays,
                                    DayCounter dayCounter, Calendar calendar, BusinessDayConvention businessDayConvention,
                                    FixedRateBond fixedCouponBond,
                                    Handle <YieldTermStructure> discountCurve,
                                    Handle <YieldTermStructure> incomeDiscountCurve)
            : base(dayCounter, calendar, businessDayConvention, settlementDays, new ForwardTypePayoff(type, strike),
                   valueDate, maturityDate, discountCurve)
        {
            fixedCouponBond_     = fixedCouponBond;
            incomeDiscountCurve_ = incomeDiscountCurve;
            incomeDiscountCurve_.registerWith(update);
        }
Beispiel #30
0
        protected HaganPricer(Handle <SwaptionVolatilityStructure> swaptionVol, GFunctionFactory.YieldCurveModel modelOfYieldCurve, Handle <Quote> meanReversion)
            : base(swaptionVol)
        {
            modelOfYieldCurve_ = modelOfYieldCurve;
            cutoffForCaplet_   = 2;
            cutoffForFloorlet_ = 0;
            meanReversion_     = meanReversion;

            if (meanReversion_.link != null)
            {
                meanReversion_.registerWith(update);
            }
        }