public KahaleSmileSection(SmileSection source, double atm) : this(NQuantLibcPINVOKE.new_KahaleSmileSection__SWIG_7(SmileSection.getCPtr(source), atm), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public KahaleSmileSection(SmileSection source, double atm, bool interpolate, bool exponentialExtrapolation) : this(NQuantLibcPINVOKE.new_KahaleSmileSection__SWIG_5(SmileSection.getCPtr(source), atm, interpolate, exponentialExtrapolation), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public KahaleSmileSection(SmileSection source, double atm, bool interpolate, bool exponentialExtrapolation, bool deleteArbitragePoints, DoubleVector moneynessGrid) : this(NQuantLibcPINVOKE.new_KahaleSmileSection__SWIG_3(SmileSection.getCPtr(source), atm, interpolate, exponentialExtrapolation, deleteArbitragePoints, DoubleVector.getCPtr(moneynessGrid)), true) { if (NQuantLibcPINVOKE.SWIGPendingException.Pending) { throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve(); } }
public AtmSmileSection(SmileSection source, double?atm = null) { source_ = source; f_ = atm; if (f_ == null) { f_ = source_.atmLevel(); } }
public void testSpreadedCube() { // Testing spreaded swaption volatility cube CommonVars vars = new CommonVars(); List <List <Handle <Quote> > > parametersGuess = new InitializedList <List <Handle <Quote> > >(vars.cube.tenors.options.Count * vars.cube.tenors.swaps.Count); for (int i = 0; i < vars.cube.tenors.options.Count * vars.cube.tenors.swaps.Count; i++) { parametersGuess[i] = new InitializedList <Handle <Quote> >(4); parametersGuess[i][0] = new Handle <Quote>(new SimpleQuote(0.2)); parametersGuess[i][1] = new Handle <Quote>(new SimpleQuote(0.5)); parametersGuess[i][2] = new Handle <Quote>(new SimpleQuote(0.4)); parametersGuess[i][3] = new Handle <Quote>(new SimpleQuote(0.0)); } List <bool> isParameterFixed = new InitializedList <bool>(4, false); Handle <SwaptionVolatilityStructure> volCube = new Handle <SwaptionVolatilityStructure>( new SwaptionVolCube1x(vars.atmVolMatrix, vars.cube.tenors.options, vars.cube.tenors.swaps, vars.cube.strikeSpreads, vars.cube.volSpreadsHandle, vars.swapIndexBase, vars.shortSwapIndexBase, vars.vegaWeighedSmileFit, parametersGuess, isParameterFixed, true)); SimpleQuote spread = new SimpleQuote(0.0001); Handle <Quote> spreadHandle = new Handle <Quote>(spread); SwaptionVolatilityStructure spreadedVolCube = new SpreadedSwaptionVolatility(volCube, spreadHandle); List <double> strikes = new List <double>(); for (int k = 1; k < 100; k++) { strikes.Add(k * .01); } for (int i = 0; i < vars.cube.tenors.options.Count; i++) { for (int j = 0; j < vars.cube.tenors.swaps.Count; j++) { SmileSection smileSectionByCube = volCube.link.smileSection(vars.cube.tenors.options[i], vars.cube.tenors.swaps[j]); SmileSection smileSectionBySpreadedCube = spreadedVolCube.smileSection(vars.cube.tenors.options[i], vars.cube.tenors.swaps[j]); for (int k = 0; k < strikes.Count; k++) { double strike = strikes[k]; double diff = spreadedVolCube.volatility(vars.cube.tenors.options[i], vars.cube.tenors.swaps[j], strike) - volCube.link.volatility(vars.cube.tenors.options[i], vars.cube.tenors.swaps[j], strike); if (Math.Abs(diff - spread.value()) > 1e-16) { QAssert.Fail("\ndiff!=spread in volatility method:" + "\nexpiry time = " + vars.cube.tenors.options[i] + "\nswap length = " + vars.cube.tenors.swaps[j] + "\n atm strike = " + (strike) + "\ndiff = " + diff + "\nspread = " + spread.value()); } diff = smileSectionBySpreadedCube.volatility(strike) - smileSectionByCube.volatility(strike); if (Math.Abs(diff - spread.value()) > 1e-16) { QAssert.Fail("\ndiff!=spread in smile section method:" + "\nexpiry time = " + vars.cube.tenors.options[i] + "\nswap length = " + vars.cube.tenors.swaps[j] + "\n atm strike = " + (strike) + "\ndiff = " + diff + "\nspread = " + spread.value()); } } } } //testing observability Flag f = new Flag(); spreadedVolCube.registerWith(f.update); volCube.link.update(); if (!f.isUp()) { QAssert.Fail("SpreadedSwaptionVolatilityStructure does not propagate notifications"); } f.lower(); spread.setValue(.001); if (!f.isUp()) { QAssert.Fail("SpreadedSwaptionVolatilityStructure does not propagate notifications"); } }
protected override SmileSection smileSectionImpl(double optionTime, double swapLength) { SmileSection baseSmile = baseVol_.link.smileSection(optionTime, swapLength, true); return(new SpreadedSmileSection(baseSmile, spread_)); }
// SwaptionVolatilityStructure interface protected override SmileSection smileSectionImpl(Date optionDate, Period swapTenor) { SmileSection baseSmile = baseVol_.link.smileSection(optionDate, swapTenor, true); return(new SpreadedSmileSection(baseSmile, spread_)); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SmileSection obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }