/// <summary> /// Gets the Wing volatility /// </summary> /// <param name="volSurface">The vol surface.</param> /// <param name="time">The time.</param> /// <param name="strike">The strike.</param> /// <param name="wingParameterList"></param> /// <returns></returns> public static double GetWingValue(List <OrcWingParameters> wingParameterList, IInterpolation xInterp, double time, double strike) { double eps = 0.0001; IPoint pt1 = new Point2D(time, strike * (1 + eps)); IPoint pt2 = new Point2D(time, strike * (1 - eps)); double[] _years = new double[wingParameterList.Count]; for (int idx = 0; idx < wingParameterList.Count; idx++) { _years[idx] = wingParameterList[idx].TimeToMaturity; } var volArray = new double[wingParameterList.Count]; for (int idx = 0; idx < wingParameterList.Count; idx++) { volArray[idx] = OrcWingVol.Value(strike, wingParameterList[idx]); } double res = 0; if (volArray.Length > 1) { xInterp.Initialize(_years, volArray); res = xInterp.ValueAt(time, false); } else { res = volArray[0]; } return(res); }
/// <summary> /// Values at, overriding calibrated Wing Model with supplied parms /// </summary> /// <param name="stock"></param> /// <param name="expiry">The expiry.</param> /// <param name="strikes">The strikes.</param> /// <param name="parms">The parms.</param> /// <param name="oride"></param> /// <param name="cache">if set to <c>true</c> [cache].</param> /// <returns></returns> public ForwardExpiry ValueAt(Stock stock, DateTime expiry, List <Double> strikes, OrcWingParameters parms, bool oride, bool cache) { var fwdExpiry = new ForwardExpiry { ExpiryDate = expiry }; double forward = stock.GetForward(stock.Date, expiry); fwdExpiry.FwdPrice = Convert.ToDecimal(forward); foreach (double strike in strikes) { double val = OrcWingVol.Value(strike, parms); IVolatilityPoint vp = new VolatilityPoint(); vp.SetVolatility(Convert.ToDecimal(val), VolatilityState.Default()); bool node = VolatilitySurfaceHelper.IsMatch(strike, expiry, NodalExpiries); Strike newstrike; if (node & oride) { newstrike = VolatilitySurfaceHelper.GetStrike(strike, expiry, NodalExpiries); //new data points, derefernce fitting model newstrike.InterpModel = null; } else { //var wingModel = new WingInterp {WingParams = parms}; newstrike = new Strike { StrikePrice = strike, InterpModel = null }; //newstrike.InterpModel = wingModel; fwdExpiry.AddStrike(newstrike, node); } newstrike.SetVolatility(vp); } return(fwdExpiry); }
/// <summary> /// Perform a wing model interpolation on a vector of values /// We must assume the points are arranged x0 <=x <= x1 for this to work/> /// </summary> /// <param name="axisValue">The axis value</param> /// <param name="extrapolation">This is not currently implemented.</param> /// <returns></returns> public double ValueAt(double axisValue, bool extrapolation) { var result = OrcWingVol.Value(axisValue, WingParameters); return(result); }