using YLErp.DBModels.Helpers; using YLErp.Modules.VolatilityModule; namespace YLErp.Modules.PricingModule { /// /// 反算波动率和执行价服务 /// public class ReverseCalcService { /// /// 根据平仓单价计算隐含波动率 /// public static double? GetImpliedUnWindVol(trade td, DateTime unWindDate, double unWindPrice, double underlyingPrice, bool isEod) { try { var trade = td.Clone(); trade.TradeSinglePrice = unWindPrice; trade.PremiumRate = TradeHelper.GetPremiumRateByTradeSinglePrice(trade.TradeSinglePrice, trade.SpotPrice); trade.BuySell = "买入"; trade.VolType = trade.BuySell == "卖出" ? "报价Bid" : "报价Ask"; return VolatilityHelper.GetImpliedVol(unWindDate, trade, trade.TTMDays, underlyingPrice, isEod); } catch (Exception ex) { LogFactory.GetLogger("计算隐含波动率").Error("根据平仓单价计算隐含波动率出错", ex); throw new ServiceException("计算隐含波动率出错,平仓单价设置偏低或偏高,内部错误信息:" + ex.Message); } } } }