//using Qdp.ComputeService.Data.CommonModels.MarketInfos; //using Qdp.Foundation.Implementations; //using Qdp.Pricing.Base.Implementations; //using Qdp.Pricing.Ecosystem.Utilities; //using System; //using System.Collections.Generic; //using System.Linq; //using YLErp.Models; //using YLErp.QdpModule.Constants; //namespace YLErp.QdpModule //{ // /// // /// 从波动率曲面上找到某点的波动率 // /// // class InterpolatedVolCalc // { // /// // /// [必需]估值日期 // /// // public DateTime? valueDate; // /// // /// [必需]某点的到期日 // /// // public DateTime? exerciseDate; // /// // /// 某点的行权价 // /// // public double strike; // /// // /// // /// // public string volSurfaceType = "StrikeVol"; // /// // /// // /// // public double spot = 0.0; // /// // /// 计算 // /// // /// 波动率曲面的期限维度 // /// 波动率曲面上各点的值 // /// 波动率曲面上各点的值 // /// // public double Calculate(string[] expireTenors, double[] strikes, double[,] vols) // { // if (expireTenors == null) // { // throw new ArgumentNullException(nameof(expireTenors)); // } // if (!valueDate.HasValue) // { // throw new ArgumentNullException(nameof(valueDate)); // } // if (!exerciseDate.HasValue) // { // throw new ArgumentNullException(nameof(exerciseDate)); // } // var qdpValueDate = new Date(valueDate.Value); // var qdpExerciseDate = new Date(exerciseDate.Value); // //解析到期日 // var dates = expireTenors.Where(n => Term.IsTerm(n)).Select(n => new Term(n).Next(qdpValueDate)).ToArray(); // var volSurfaceData = new VolSurfMktData("tempVolSurface", dates, strikes, vols, ConsVolMethod.BiLinear, volSurfaceType); // var volSurface = volSurfaceData.ToImpliedVolSurface(qdpValueDate); // return volSurface.GetValue(qdpExerciseDate, strike, spot); // } // /// // /// // /// // /// // /// // public double Calculate(IEnumerable vols) // { // if (vols == null || !vols.Any()) // { // return double.NaN; // } // var vector = VolSurfaceVector.Create(vols); // return Calculate(vector.expires, vector.strikes, vector.vols); // } // } //}