85 lines
2.9 KiB
C#
85 lines
2.9 KiB
C#
//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
|
|
//{
|
|
// /// <summary>
|
|
// /// 从波动率曲面上找到某点的波动率
|
|
// /// </summary>
|
|
// class InterpolatedVolCalc
|
|
// {
|
|
// /// <summary>
|
|
// /// [必需]估值日期
|
|
// /// </summary>
|
|
// public DateTime? valueDate;
|
|
// /// <summary>
|
|
// /// [必需]某点的到期日
|
|
// /// </summary>
|
|
// public DateTime? exerciseDate;
|
|
// /// <summary>
|
|
// /// 某点的行权价
|
|
// /// </summary>
|
|
// public double strike;
|
|
// /// <summary>
|
|
// ///
|
|
// /// </summary>
|
|
// public string volSurfaceType = "StrikeVol";
|
|
// /// <summary>
|
|
// ///
|
|
// /// </summary>
|
|
// public double spot = 0.0;
|
|
|
|
// /// <summary>
|
|
// /// 计算
|
|
// /// </summary>
|
|
// /// <param name="expireTenors">波动率曲面的期限维度</param>
|
|
// /// <param name="strikes">波动率曲面上各点的值</param>
|
|
// /// <param name="vols">波动率曲面上各点的值</param>
|
|
// /// <returns></returns>
|
|
// 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);
|
|
// }
|
|
|
|
// /// <summary>
|
|
// ///
|
|
// /// </summary>
|
|
// /// <param name="vols"></param>
|
|
// /// <returns></returns>
|
|
// public double Calculate(IEnumerable<SingleVol> vols)
|
|
// {
|
|
// if (vols == null || !vols.Any())
|
|
// {
|
|
// return double.NaN;
|
|
// }
|
|
// var vector = VolSurfaceVector.Create(vols);
|
|
// return Calculate(vector.expires, vector.strikes, vector.vols);
|
|
// }
|
|
// }
|
|
//}
|