public static object TurnbullWakemanFuturesPV( [ExcelArgument(Description = "Fixing dates")] double[] FixingDates, [ExcelArgument(Description = "Eval date")] DateTime EvalDate, [ExcelArgument(Description = "Pay date")] DateTime PayDate, [ExcelArgument(Description = "Forward curve")] string Curve, [ExcelArgument(Description = "Fixings")] string FixingDictionary, [ExcelArgument(Description = "Vol surface")] string Surface, [ExcelArgument(Description = "Strike")] double K, [ExcelArgument(Description = "Discounting rate")] double R, [ExcelArgument(Description = "Call or Put")] string CP) { return(ExcelHelper.Execute(_logger, () => { if (!Enum.TryParse(CP, out OptionType optType)) { return $"Could not parse call or put flag - {CP}"; } var curve = ContainerStores.GetObjectCache <IPriceCurve>().GetObjectOrThrow(Curve, $"Curve {Curve} not found"); var surface = ContainerStores.GetObjectCache <IVolSurface>().GetObjectOrThrow(Surface, $"Surface {Surface} not found"); var fd = new FixingDictionary(); var dates = FixingDates.ToDateTimeArray(); if (dates.First() < EvalDate) { fd = ContainerStores.GetObjectCache <FixingDictionary>().GetObjectOrThrow(FixingDictionary, $"Fixing dictionary {FixingDictionary} not found").Value; } var fwds = dates.Select(d => d > EvalDate?curve.Value.GetPriceForDate(d): fd.GetFixing(d)).ToArray(); var vols = dates.Select((d, ix) => surface.Value.GetVolForAbsoluteStrike(K, d, fwds[ix])).ToArray(); return Qwack.Options.Asians.TurnbullWakeman.PV(fwds, dates, EvalDate, PayDate, vols, K, R, optType); })); }
public static object TurnbullWakemanStrikeForPVFutures( [ExcelArgument(Description = "Evaluation Date")] DateTime EvalDate, [ExcelArgument(Description = "Fixing dates")] double[] FixingDates, [ExcelArgument(Description = "Settlement Date")] DateTime PayDate, [ExcelArgument(Description = "Target PV")] double PV, [ExcelArgument(Description = "Forward curve")] string FwdCurve, [ExcelArgument(Description = "Fixing dictionary")] string FixingDictionary, [ExcelArgument(Description = "Discounting rate")] double R, [ExcelArgument(Description = "Volatility Surface")] string VolSurface, [ExcelArgument(Description = "Call or Put")] string CP) { return(ExcelHelper.Execute(_logger, () => { var surface = ContainerStores.GetObjectCache <IVolSurface>().GetObjectOrThrow(VolSurface, $"Could not parse find vol surface {VolSurface} in the cache"); var curve = ContainerStores.GetObjectCache <IPriceCurve>().GetObjectOrThrow(FwdCurve, $"Fwd curve {FwdCurve} not found"); var fd = new FixingDictionary(); var dates = FixingDates.ToDateTimeArray(); if (dates.First() < EvalDate) { fd = ContainerStores.GetObjectCache <FixingDictionary>().GetObjectOrThrow(FixingDictionary, $"Fixing dictionary {FixingDictionary} not found").Value; } var F = dates.Select(d => d > EvalDate ? curve.Value.GetPriceForDate(d) : fd.GetFixing(d)).ToArray(); if (!Enum.TryParse(CP, out OptionType optType)) { return $"Could not parse call or put flag - {CP}"; } return Qwack.Options.Asians.TurnbullWakeman.StrikeForPV(PV, F, FixingDates.ToDateTimeArray(), surface.Value, EvalDate, PayDate, R, optType); })); }