public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 3373707: // name this.name = (IborCapletFloorletVolatilitiesName)newValue; break; case 100346066: // index this.index = (IborIndex)newValue; break; case 1905311443: // dayCount this.dayCount = (DayCount)newValue; break; case 2096253127: // interpolator this.interpolator = (GridSurfaceInterpolator)newValue; break; case 1908090253: // shiftCurve this.shiftCurve = (Curve)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(DirectIborCapletFloorletVolatilityDefinition beanToCopy) { this.name_Renamed = beanToCopy.Name; this.index_Renamed = beanToCopy.Index; this.dayCount_Renamed = beanToCopy.DayCount; this.lambdaExpiry_Renamed = beanToCopy.LambdaExpiry; this.lambdaStrike_Renamed = beanToCopy.LambdaStrike; this.interpolator_Renamed = beanToCopy.Interpolator; this.shiftCurve_Renamed = beanToCopy.shiftCurve; }
public virtual void test_of_shift() { SurfaceIborCapletFloorletVolatilityBootstrapDefinition test = SurfaceIborCapletFloorletVolatilityBootstrapDefinition.of(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, STEP_UPPER, DOUBLE_QUADRATIC, SHIFT); assertEquals(test.DayCount, ACT_ACT_ISDA); assertEquals(test.Index, USD_LIBOR_3M); assertEquals(test.Interpolator, GridSurfaceInterpolator.of(STEP_UPPER, DOUBLE_QUADRATIC)); assertEquals(test.Name, NAME); assertEquals(test.ShiftCurve.get(), SHIFT); }
public virtual void test_of_surface() { GridSurfaceInterpolator interp = GridSurfaceInterpolator.of(LINEAR, LINEAR); SurfaceIborCapletFloorletVolatilityBootstrapDefinition test = SurfaceIborCapletFloorletVolatilityBootstrapDefinition.of(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, interp); assertEquals(test.DayCount, ACT_ACT_ISDA); assertEquals(test.Index, USD_LIBOR_3M); assertEquals(test.Interpolator, interp); assertEquals(test.Name, NAME); assertFalse(test.ShiftCurve.Present); }
private SurfaceIborCapletFloorletVolatilityBootstrapDefinition(IborCapletFloorletVolatilitiesName name, IborIndex index, DayCount dayCount, GridSurfaceInterpolator interpolator, Curve shiftCurve) { JodaBeanUtils.notNull(name, "name"); JodaBeanUtils.notNull(index, "index"); JodaBeanUtils.notNull(dayCount, "dayCount"); JodaBeanUtils.notNull(interpolator, "interpolator"); this.name = name; this.index = index; this.dayCount = dayCount; this.interpolator = interpolator; this.shiftCurve = shiftCurve; validate(); }
private DirectIborCapletFloorletVolatilityDefinition(IborCapletFloorletVolatilitiesName name, IborIndex index, DayCount dayCount, double lambdaExpiry, double lambdaStrike, GridSurfaceInterpolator interpolator, Curve shiftCurve) { JodaBeanUtils.notNull(name, "name"); JodaBeanUtils.notNull(index, "index"); JodaBeanUtils.notNull(dayCount, "dayCount"); ArgChecker.notNegative(lambdaExpiry, "lambdaExpiry"); ArgChecker.notNegative(lambdaStrike, "lambdaStrike"); JodaBeanUtils.notNull(interpolator, "interpolator"); this.name = name; this.index = index; this.dayCount = dayCount; this.lambdaExpiry = lambdaExpiry; this.lambdaStrike = lambdaStrike; this.interpolator = interpolator; this.shiftCurve = shiftCurve; }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 3373707: // name this.name_Renamed = (IborCapletFloorletVolatilitiesName)newValue; break; case 100346066: // index this.index_Renamed = (IborIndex)newValue; break; case 1905311443: // dayCount this.dayCount_Renamed = (DayCount)newValue; break; case -1966011430: // lambdaExpiry this.lambdaExpiry_Renamed = (double?)newValue.Value; break; case -1568838055: // lambdaStrike this.lambdaStrike_Renamed = (double?)newValue.Value; break; case 2096253127: // interpolator this.interpolator_Renamed = (GridSurfaceInterpolator)newValue; break; case 1908090253: // shiftCurve this.shiftCurve_Renamed = (Curve)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
//------------------------------------------------------------------------- public virtual void coverage() { coverImmutableBean(VOLS); ShiftedBlackIborCapletFloorletExpiryStrikeVolatilities vols = ShiftedBlackIborCapletFloorletExpiryStrikeVolatilities.of(USD_LIBOR_3M, VAL_DATE_TIME.plusMonths(1), InterpolatedNodalSurface.of(METADATA, TIME, STRIKE, VOL, GridSurfaceInterpolator.of(TIME_SQUARE, LINEAR)), ConstantCurve.of("shift", 0.05)); coverBeanEquals(VOLS, vols); }
/// <summary> /// Sets the interpolator for the caplet volatilities. </summary> /// <param name="interpolator"> the new value, not null </param> /// <returns> this, for chaining, not null </returns> public Builder interpolator(GridSurfaceInterpolator interpolator) { JodaBeanUtils.notNull(interpolator, "interpolator"); this.interpolator_Renamed = interpolator; return(this); }
/// <summary> /// Obtains an instance with shift curve. /// </summary> /// <param name="name"> the name of the volatilities </param> /// <param name="index"> the Ibor index </param> /// <param name="dayCount"> the day count to use </param> /// <param name="lambdaExpiry"> the penalty intensity parameter for time dimension </param> /// <param name="lambdaStrike"> the penalty intensity parameter for strike dimension </param> /// <param name="interpolator"> the surface interpolator </param> /// <param name="shiftCurve"> the shift surface </param> /// <returns> the instance </returns> public static DirectIborCapletFloorletVolatilityDefinition of(IborCapletFloorletVolatilitiesName name, IborIndex index, DayCount dayCount, double lambdaExpiry, double lambdaStrike, GridSurfaceInterpolator interpolator, Curve shiftCurve) { return(new DirectIborCapletFloorletVolatilityDefinition(name, index, dayCount, lambdaExpiry, lambdaStrike, interpolator, shiftCurve)); }
static FxOptionVolatilitiesMarketDataFunctionTest() { ImmutableList.Builder <FxOptionVolatilitiesNode> volNodeBuilder = ImmutableList.builder(); ImmutableMap.Builder <QuoteId, double> marketQuoteBuilder = ImmutableMap.builder(); ImmutableMap.Builder <QuoteId, MarketDataBox <double> > scenarioMarketQuoteBuilder = ImmutableMap.builder(); ImmutableList.Builder <FixedOvernightSwapCurveNode> usdNodeBuilder = ImmutableList.builder(); ImmutableList.Builder <FxSwapCurveNode> gbpNodeBuilder = ImmutableList.builder(); for (int i = 0; i < VOL_TENORS.Count; ++i) { for (int j = 0; j < STRIKES.Count; ++j) { QuoteId quoteId = QuoteId.of(StandardId.of("OG", VOL_TENORS[i].ToString() + "_" + STRIKES[j].Label + "_" + VALUE_TYPES[j].ToString())); volNodeBuilder.add(FxOptionVolatilitiesNode.of(GBP_USD, SPOT_OFFSET, BDA, VALUE_TYPES[j], quoteId, VOL_TENORS[i], STRIKES[j])); marketQuoteBuilder.put(quoteId, VOL_QUOTES[i][j]); scenarioMarketQuoteBuilder.put(quoteId, MarketDataBox.ofScenarioValues(VOL_QUOTES[i][j], VOL_QUOTES_1[i][j])); } } for (int i = 0; i < USD_QUOTES.Count; ++i) { QuoteId quoteId = QuoteId.of(StandardId.of("OG", USD.ToString() + "-OIS-" + USD_TENORS[i].ToString())); usdNodeBuilder.add(FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(USD_TENORS[i], FixedOvernightSwapConventions.USD_FIXED_TERM_FED_FUND_OIS), quoteId)); marketQuoteBuilder.put(quoteId, USD_QUOTES[i]); scenarioMarketQuoteBuilder.put(quoteId, MarketDataBox.ofScenarioValues(USD_QUOTES[i], USD_QUOTES_1[i])); } for (int i = 0; i < GBP_QUOTES.Count; ++i) { QuoteId quoteId = QuoteId.of(StandardId.of("OG", GBP_USD.ToString() + "-FX-" + GBP_PERIODS[i].ToString())); gbpNodeBuilder.add(FxSwapCurveNode.of(FxSwapTemplate.of(GBP_PERIODS[i], FxSwapConventions.GBP_USD), quoteId)); marketQuoteBuilder.put(quoteId, GBP_QUOTES[i]); scenarioMarketQuoteBuilder.put(quoteId, MarketDataBox.ofScenarioValues(GBP_QUOTES[i], GBP_QUOTES_1[i])); } VOL_NODES = volNodeBuilder.build(); USD_NODES = usdNodeBuilder.build(); GBP_NODES = gbpNodeBuilder.build(); MARKET_QUOTES = marketQuoteBuilder.build(); SCENARIO_MARKET_QUOTES = scenarioMarketQuoteBuilder.build(); IList <double> expiry = VOL_TENORS.Select(t => ACT_365F.relativeYearFraction(VALUATION_DATE, BDA.adjust(SPOT_OFFSET.adjust(VALUATION_DATE, REF_DATA).plus(t), REF_DATA))).ToList(); int nSmiles = expiry.Count; double[] atm = new double[nSmiles]; //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: double[][] rr = new double[nSmiles][2]; double[][] rr = RectangularArrays.ReturnRectangularDoubleArray(nSmiles, 2); //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: double[][] str = new double[nSmiles][2]; double[][] str = RectangularArrays.ReturnRectangularDoubleArray(nSmiles, 2); for (int i = 0; i < nSmiles; ++i) { atm[i] = VOL_QUOTES[i][0]; rr[i][0] = VOL_QUOTES[i][1]; rr[i][1] = VOL_QUOTES[i][3]; str[i][0] = VOL_QUOTES[i][2]; str[i][1] = VOL_QUOTES[i][4]; } InterpolatedStrikeSmileDeltaTermStructure term = InterpolatedStrikeSmileDeltaTermStructure.of(DoubleArray.copyOf(expiry), DoubleArray.of(0.1, 0.25), DoubleArray.copyOf(atm), DoubleMatrix.copyOf(rr), DoubleMatrix.copyOf(str), ACT_365F, LINEAR, FLAT, FLAT, PCHIP, FLAT, FLAT); EXP_VOLS = BlackFxOptionSmileVolatilities.of(VOL_NAME, GBP_USD, VALUATION_DATE.atTime(VALUATION_TIME).atZone(ZONE), term); for (int i = 0; i < nSmiles; ++i) { atm[i] = VOL_QUOTES_1[i][0]; rr[i][0] = VOL_QUOTES_1[i][1]; rr[i][1] = VOL_QUOTES_1[i][3]; str[i][0] = VOL_QUOTES_1[i][2]; str[i][1] = VOL_QUOTES_1[i][4]; } InterpolatedStrikeSmileDeltaTermStructure term1 = InterpolatedStrikeSmileDeltaTermStructure.of(DoubleArray.copyOf(expiry), DoubleArray.of(0.1, 0.25), DoubleArray.copyOf(atm), DoubleMatrix.copyOf(rr), DoubleMatrix.copyOf(str), ACT_365F, LINEAR, FLAT, FLAT, PCHIP, FLAT, FLAT); EXP_VOLS_1 = BlackFxOptionSmileVolatilities.of(VOL_NAME, GBP_USD, VALUATION_DATE_1.atTime(VALUATION_TIME_1).atZone(ZONE), term1); ImmutableList.Builder <FxOptionVolatilitiesNode> nodeBuilder = ImmutableList.builder(); ImmutableMap.Builder <QuoteId, double> quoteBuilder = ImmutableMap.builder(); for (int i = 0; i < SURFACE_TENORS.Count; ++i) { for (int j = 0; j < SURFACE_STRIKES.Count; ++j) { QuoteId quoteId = QuoteId.of(StandardId.of("OG", GBP_USD.ToString() + "_" + SURFACE_TENORS[i].ToString() + "_" + SURFACE_STRIKES[j])); quoteBuilder.put(quoteId, SURFACE_VOL_QUOTES[i][j]); nodeBuilder.add(FxOptionVolatilitiesNode.of(GBP_USD, SPOT_OFFSET, BDA, ValueType.BLACK_VOLATILITY, quoteId, SURFACE_TENORS[i], SimpleStrike.of(SURFACE_STRIKES[j]))); } } SURFACE_NODES = nodeBuilder.build(); SURFACE_QUOTES = quoteBuilder.build(); IList <double> expiry = new List <double>(); IList <double> strike = new List <double>(); IList <double> vols = new List <double>(); for (int i = 0; i < SURFACE_TENORS.Count; ++i) { for (int j = 0; j < SURFACE_STRIKES.Count; ++j) { double yearFraction = ACT_365F.relativeYearFraction(VALUATION_DATE, BDA.adjust(SPOT_OFFSET.adjust(VALUATION_DATE, REF_DATA).plus(SURFACE_TENORS[i]), REF_DATA)); expiry.Add(yearFraction); strike.Add(SURFACE_STRIKES[j]); vols.Add(SURFACE_VOL_QUOTES[i][j]); } } SurfaceInterpolator interp = GridSurfaceInterpolator.of(LINEAR, PCHIP); InterpolatedNodalSurface surface = InterpolatedNodalSurface.ofUnsorted(Surfaces.blackVolatilityByExpiryStrike(VOL_NAME.Name, ACT_365F), DoubleArray.copyOf(expiry), DoubleArray.copyOf(strike), DoubleArray.copyOf(vols), interp); SURFACE_EXP_VOLS = BlackFxOptionSurfaceVolatilities.of(VOL_NAME, GBP_USD, VALUATION_DATE.atTime(VALUATION_TIME).atZone(ZONE), surface); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance with gird surface interpolator. /// </summary> /// <param name="name"> the name of the volatilities </param> /// <param name="index"> the Ibor index </param> /// <param name="dayCount"> the day count to use </param> /// <param name="interpolator"> the surface interpolator </param> /// <returns> the instance </returns> public static SurfaceIborCapletFloorletVolatilityBootstrapDefinition of(IborCapletFloorletVolatilitiesName name, IborIndex index, DayCount dayCount, GridSurfaceInterpolator interpolator) { return(of(name, index, dayCount, interpolator, null)); }
/// <summary> /// Obtains an instance with time interpolator, strike interpolator and shift curve. /// <para> /// The extrapolation is completed by default extrapolators in {@code GridSurfaceInterpolator}. /// /// </para> /// </summary> /// <param name="name"> the name of the volatilities </param> /// <param name="index"> the Ibor index </param> /// <param name="dayCount"> the day count to use </param> /// <param name="timeInterpolator"> the time interpolator </param> /// <param name="strikeInterpolator"> the strike interpolator </param> /// <param name="shiftCurve"> the shift curve </param> /// <returns> the instance </returns> public static SurfaceIborCapletFloorletVolatilityBootstrapDefinition of(IborCapletFloorletVolatilitiesName name, IborIndex index, DayCount dayCount, CurveInterpolator timeInterpolator, CurveInterpolator strikeInterpolator, Curve shiftCurve) { GridSurfaceInterpolator gridInterpolator = GridSurfaceInterpolator.of(timeInterpolator, strikeInterpolator); return(of(name, index, dayCount, gridInterpolator, shiftCurve)); }
/// <summary> /// Obtains an instance with gird surface interpolator and shift curve. /// </summary> /// <param name="name"> the name of the volatilities </param> /// <param name="index"> the Ibor index </param> /// <param name="dayCount"> the day count to use </param> /// <param name="interpolator"> the surface interpolator </param> /// <param name="shiftCurve"> the shift curve </param> /// <returns> the instance </returns> public static SurfaceIborCapletFloorletVolatilityBootstrapDefinition of(IborCapletFloorletVolatilitiesName name, IborIndex index, DayCount dayCount, GridSurfaceInterpolator interpolator, Curve shiftCurve) { return(new SurfaceIborCapletFloorletVolatilityBootstrapDefinition(name, index, dayCount, interpolator, shiftCurve)); }
public virtual void test_volatilities() { BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification @base = BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification.builder().name(VOL_NAME).currencyPair(GBP_USD).dayCount(ACT_365F).nodes(NODES).timeInterpolator(PCHIP).strikeInterpolator(DOUBLE_QUADRATIC).build(); LocalDate date = LocalDate.of(2017, 9, 25); ZonedDateTime dateTime = date.atStartOfDay().atZone(ZoneId.of("Europe/London")); DoubleArray parameters = DoubleArray.of(0.19, 0.15, 0.13, 0.14, 0.14, 0.11, 0.09, 0.09, 0.11, 0.09, 0.07, 0.07); BlackFxOptionSurfaceVolatilities computed = @base.volatilities(dateTime, parameters, REF_DATA); DaysAdjustment expOffset = DaysAdjustment.ofBusinessDays(-2, NY_LO); double[] expiries = new double[STRIKES.Count * TENORS.Count]; double[] strikes = new double[STRIKES.Count * TENORS.Count]; ImmutableList.Builder <ParameterMetadata> paramMetadata = ImmutableList.builder(); for (int i = 0; i < TENORS.Count; ++i) { double expiry = ACT_365F.relativeYearFraction(date, expOffset.adjust(BDA.adjust(SPOT_OFFSET.adjust(date, REF_DATA).plus(TENORS[i]), REF_DATA), REF_DATA)); for (int j = 0; j < STRIKES.Count; ++j) { paramMetadata.add(FxVolatilitySurfaceYearFractionParameterMetadata.of(expiry, SimpleStrike.of(STRIKES[j]), GBP_USD)); expiries[STRIKES.Count * i + j] = expiry; strikes[STRIKES.Count * i + j] = STRIKES[j]; } } InterpolatedNodalSurface surface = InterpolatedNodalSurface.ofUnsorted(Surfaces.blackVolatilityByExpiryStrike(VOL_NAME.Name, ACT_365F).withParameterMetadata(paramMetadata.build()), DoubleArray.ofUnsafe(expiries), DoubleArray.ofUnsafe(strikes), parameters, GridSurfaceInterpolator.of(PCHIP, DOUBLE_QUADRATIC)); BlackFxOptionSurfaceVolatilities expected = BlackFxOptionSurfaceVolatilities.of(VOL_NAME, GBP_USD, dateTime, surface); assertEquals(computed, expected); }