/// <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> /// Failures the specified exception. /// </summary> /// <param name="exception">The exception.</param> /// <returns></returns> public static VolatilityState Failure(System.Exception exception) { VolatilityState state = new VolatilityState(VolatilityStateType.Failure, exception.GetBaseException().Message) { FailureException = exception }; return(state); }
/// <summary> /// Values at. /// </summary> /// <param name="stock"></param> /// <param name="expiries">The expiries.</param> /// <param name="strikes">The strikes.</param> /// <param name="?">Cache to vol object</param> /// <param name="cache"></param> /// <returns></returns> public List <ForwardExpiry> ValueAt(Stock stock, List <DateTime> expiries, List <Double> strikes, bool cache) { var forwardExpiries = new List <ForwardExpiry>(); foreach (DateTime exp in expiries) { var fwdExpiry = new ForwardExpiry(); foreach (double str in strikes) { var wingModel = new WingInterp(); double forward = stock.GetForward(stock.Date, exp.Date); double spot = Convert.ToDouble(stock.Spot); fwdExpiry.FwdPrice = Convert.ToDecimal(forward); double y = str; double x = (exp.Subtract(Date)).Days / 365.0; IPoint point = new Point2D(x, y); InterpCurve.Forward = forward; InterpCurve.Spot = spot; var val = InterpCurve.Value(point); IVolatilityPoint vp = new VolatilityPoint(); vp.SetVolatility(Convert.ToDecimal(val), VolatilityState.Default()); fwdExpiry.ExpiryDate = exp; bool node = VolatilitySurfaceHelper.IsMatch(str, exp, NodalExpiries); // copy model used to return ForwardExpiry object var newstrike = new Strike { StrikePrice = str }; var wing = (WingModelInterpolation)InterpCurve.GetYAxisInterpolatingFunction(); //SABRModelInterpolation wing = (SABRModelInterpolation)_interpCurve.GetYAxisInterpolatingFunction(); wingModel.WingParams = wing.WingParameters; newstrike.InterpModel = wingModel; fwdExpiry.AddStrike(newstrike, node); newstrike.SetVolatility(vp); } forwardExpiries.Add(fwdExpiry); } return(forwardExpiries); }
/// <summary> /// Defaults this instance. /// </summary> /// <returns></returns> public static VolatilityState Default() { VolatilityState state = new VolatilityState(VolatilityStateType.Default, string.Empty); return(state); }