public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 2100884654:         // volatilitiesName
                    this.volatilitiesName = (SwaptionVolatilitiesName)newValue;
                    break;

                case -1289159373:         // expiry
                    this.expiry = (double?)newValue.Value;
                    break;

                case 110246592:         // tenor
                    this.tenor = (double?)newValue.Value;
                    break;

                case 1598929529:         // sensitivityType
                    this.sensitivityType = (SabrParameterType)newValue;
                    break;

                case 575402001:         // currency
                    this.currency = (Currency)newValue;
                    break;

                case 564403871:         // sensitivity
                    this.sensitivity = (double?)newValue.Value;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value sensitivity to the SABR model parameters of the swaption product.
        /// <para>
        /// The sensitivity of the present value to the SABR model parameters, alpha, beta, rho and nu.
        ///
        /// </para>
        /// </summary>
        /// <param name="swaption">  the swaption product </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the volatilities </param>
        /// <returns> the point sensitivity to the SABR model parameters </returns>
        public virtual PointSensitivityBuilder presentValueSensitivityModelParamsSabr(ResolvedSwaption swaption, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities)
        {
            validate(swaption, ratesProvider, swaptionVolatilities);
            double          expiry     = swaptionVolatilities.relativeTime(swaption.Expiry);
            ResolvedSwap    underlying = swaption.Underlying;
            ResolvedSwapLeg fixedLeg   = this.fixedLeg(underlying);
            double          tenor      = swaptionVolatilities.tenor(fixedLeg.StartDate, fixedLeg.EndDate);
            double          shift      = swaptionVolatilities.shift(expiry, tenor);
            double          pvbp       = SwapPricer.LegPricer.pvbp(fixedLeg, ratesProvider);
            double          strike     = SwapPricer.LegPricer.couponEquivalent(fixedLeg, ratesProvider, pvbp);

            if (expiry < 0d)
            {     // Option has expired already
                return(PointSensitivityBuilder.none());
            }
            double      forward    = SwapPricer.parRate(underlying, ratesProvider);
            double      volatility = swaptionVolatilities.volatility(expiry, tenor, strike, forward);
            DoubleArray derivative = swaptionVolatilities.volatilityAdjoint(expiry, tenor, strike, forward).Derivatives;
            // Backward sweep
            double vega = Math.Abs(pvbp) * BlackFormulaRepository.vega(forward + shift, strike + shift, expiry, volatility) * swaption.LongShort.sign();
            // sensitivities
            Currency ccy = fixedLeg.Currency;
            SwaptionVolatilitiesName name = swaptionVolatilities.Name;

            return(PointSensitivityBuilder.of(SwaptionSabrSensitivity.of(name, expiry, tenor, ALPHA, ccy, vega * derivative.get(2)), SwaptionSabrSensitivity.of(name, expiry, tenor, BETA, ccy, vega * derivative.get(3)), SwaptionSabrSensitivity.of(name, expiry, tenor, RHO, ccy, vega * derivative.get(4)), SwaptionSabrSensitivity.of(name, expiry, tenor, NU, ccy, vega * derivative.get(5))));
        }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3373707:         // name
                    this.name = (SwaptionVolatilitiesName)newValue;
                    break;

                case 2039569265:         // convention
                    this.convention = (FixedIborSwapConvention)newValue;
                    break;

                case 1905311443:         // dayCount
                    this.dayCount = (DayCount)newValue;
                    break;

                case 2096253127:         // interpolator
                    this.interpolator = (SurfaceInterpolator)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
示例#4
0
        public virtual void test_of_object()
        {
            SwaptionVolatilitiesId test = SwaptionVolatilitiesId.of(SwaptionVolatilitiesName.of("Foo"));

            assertEquals(test.Name, SwaptionVolatilitiesName.of("Foo"));
            assertEquals(test.MarketDataType, typeof(SwaptionVolatilities));
            assertEquals(test.MarketDataName, SwaptionVolatilitiesName.of("Foo"));
            assertEquals(test.ToString(), "SwaptionVolatilitiesId:Foo");
        }
        public virtual void test_of()
        {
            SwaptionVolatilitiesName test = SwaptionVolatilitiesName.of("Foo");

            assertEquals(test.Name, "Foo");
            assertEquals(test.MarketDataType, typeof(SwaptionVolatilities));
            assertEquals(test.ToString(), "Foo");
            assertEquals(test.CompareTo(SwaptionVolatilitiesName.of("Goo")) < 0, true);
        }
 private SwaptionSabrSensitivity(SwaptionVolatilitiesName volatilitiesName, double expiry, double tenor, SabrParameterType sensitivityType, Currency currency, double sensitivity)
 {
     JodaBeanUtils.notNull(volatilitiesName, "volatilitiesName");
     JodaBeanUtils.notNull(expiry, "expiry");
     this.volatilitiesName = volatilitiesName;
     this.expiry           = expiry;
     this.tenor            = tenor;
     this.sensitivityType  = sensitivityType;
     this.currency         = currency;
     this.sensitivity      = sensitivity;
 }
 private SabrSwaptionDefinition(SwaptionVolatilitiesName name, FixedIborSwapConvention convention, DayCount dayCount, SurfaceInterpolator interpolator)
 {
     JodaBeanUtils.notNull(name, "name");
     JodaBeanUtils.notNull(convention, "convention");
     JodaBeanUtils.notNull(dayCount, "dayCount");
     JodaBeanUtils.notNull(interpolator, "interpolator");
     this.name         = name;
     this.convention   = convention;
     this.dayCount     = dayCount;
     this.interpolator = interpolator;
 }
 private SwaptionSensitivity(SwaptionVolatilitiesName volatilitiesName, double expiry, double tenor, double strike, double forward, Currency currency, double sensitivity)
 {
     JodaBeanUtils.notNull(volatilitiesName, "volatilitiesName");
     JodaBeanUtils.notNull(expiry, "expiry");
     JodaBeanUtils.notNull(currency, "currency");
     this.volatilitiesName = volatilitiesName;
     this.expiry           = expiry;
     this.tenor            = tenor;
     this.strike           = strike;
     this.forward          = forward;
     this.currency         = currency;
     this.sensitivity      = sensitivity;
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from the specified elements.
 /// </summary>
 /// <param name="volatilitiesName">  the name of the volatilities </param>
 /// <param name="expiry">  the time to expiry of the option as a year fraction </param>
 /// <param name="tenor">  the underlying swap tenor </param>
 /// <param name="strike">  the swaption strike rate </param>
 /// <param name="forward">  the underlying swap forward rate </param>
 /// <param name="sensitivityCurrency">  the currency of the sensitivity </param>
 /// <param name="sensitivity">  the value of the sensitivity </param>
 /// <returns> the point sensitivity object </returns>
 public static SwaptionSensitivity of(SwaptionVolatilitiesName volatilitiesName, double expiry, double tenor, double strike, double forward, Currency sensitivityCurrency, double sensitivity)
 {
     return(new SwaptionSensitivity(volatilitiesName, expiry, tenor, strike, forward, sensitivityCurrency, sensitivity));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from the specified elements.
 /// </summary>
 /// <param name="volatilitiesName">  the name of the volatilities </param>
 /// <param name="expiry">  the time to expiry of the option as a year fraction </param>
 /// <param name="tenor">  the underlying swap tenor </param>
 /// <param name="sensitivityType">  the type of the sensitivity </param>
 /// <param name="sensitivityCurrency">  the currency of the sensitivity </param>
 /// <param name="sensitivity">  the value of the sensitivity </param>
 /// <returns> the sensitivity object </returns>
 public static SwaptionSabrSensitivity of(SwaptionVolatilitiesName volatilitiesName, double expiry, double tenor, SabrParameterType sensitivityType, Currency sensitivityCurrency, double sensitivity)
 {
     return(new SwaptionSabrSensitivity(volatilitiesName, expiry, tenor, sensitivityType, sensitivityCurrency, sensitivity));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from the name, convention, day count and tenors.
 /// </summary>
 /// <param name="name">  the name of the volatilities </param>
 /// <param name="convention">  the swap convention that the volatilities are to be used for </param>
 /// <param name="dayCount">  the day count to use </param>
 /// <param name="interpolator">  the interpolator for the alpha, rho and nu surfaces </param>
 /// <returns> the volatilities </returns>
 public static SabrSwaptionDefinition of(SwaptionVolatilitiesName name, FixedIborSwapConvention convention, DayCount dayCount, SurfaceInterpolator interpolator)
 {
     return(new SabrSwaptionDefinition(name, convention, dayCount, interpolator));
 }
示例#12
0
 /// <summary>
 /// Obtains an identifier used to find swaption volatilities.
 /// </summary>
 /// <param name="name">  the name </param>
 /// <returns> an identifier for the volatilities </returns>
 public static SwaptionVolatilitiesId of(SwaptionVolatilitiesName name)
 {
     return(new SwaptionVolatilitiesId(name));
 }
示例#13
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an identifier used to find swaption volatilities.
 /// </summary>
 /// <param name="name">  the name </param>
 /// <returns> an identifier for the volatilities </returns>
 public static SwaptionVolatilitiesId of(string name)
 {
     return(new SwaptionVolatilitiesId(SwaptionVolatilitiesName.of(name)));
 }
示例#14
0
 private SwaptionVolatilitiesId(SwaptionVolatilitiesName name)
 {
     JodaBeanUtils.notNull(name, "name");
     this.name = name;
 }