public static double CalculateVega(Entities.OptionType type, double settleprice, double strike, double volatility, double daystomate, double risk_free) { double pdaystomate = daystomate / YearLength; double d1 = (Math.Log(settleprice / strike) + volatility * volatility * 0.5 * pdaystomate) / (volatility * Math.Sqrt(pdaystomate)); return(settleprice * NormalDistributionDensity(d1) * Math.Exp(-1 * risk_free * pdaystomate) * Math.Sqrt(pdaystomate) / 100); }
public static double CalculateDelta(Entities.OptionType type, double settleprice, double strike, double volatility, double daystomate, double risk_free) { double pdaystomate = daystomate / YearLength; double d1 = (Math.Log(settleprice / strike) + volatility * volatility * 0.5 * pdaystomate) / (volatility * Math.Sqrt(pdaystomate)); if (type == Entities.OptionType.Call) { return(Math.Exp((-1 * risk_free * pdaystomate) * NormalDistribution(d1))); } else if (type == Entities.OptionType.Put) { return(-1.0 * Math.Exp(-1.0 * risk_free * pdaystomate) * NormalDistribution(-1.0 * d1)); } else { return(0); } }
public static double CalculateRho(Entities.OptionType type, double settleprice, double strike, double volatility, int daystomate, double risk_free) { double pdaystomate = (double)daystomate / YearLength; double d1 = (Math.Log(settleprice / strike) + volatility * volatility * 0.5 * pdaystomate) / (volatility * Math.Sqrt(pdaystomate)); double d2 = d1 - volatility * Math.Sqrt(pdaystomate); if (type == Entities.OptionType.Call) { return(pdaystomate * strike * Math.Exp(-1 * risk_free * pdaystomate) * NormalDistribution(d2) / 100); } else if (type == Entities.OptionType.Put) { return(-1 * pdaystomate * strike * Math.Exp(-1 * risk_free * pdaystomate) * NormalDistribution(-1 * d2) / 100); } else { return(0); } }
public static double CalculateThetha(Entities.OptionType type, double settleprice, double strike, double volatility, double daystomate, double risk_free) { double pdaystomate = daystomate / YearLength; double d1 = (Math.Log(settleprice / strike) + volatility * volatility * 0.5 * pdaystomate) / (volatility * Math.Sqrt(pdaystomate)); double temp = settleprice * Math.Exp(-1 * risk_free * pdaystomate); double d2 = d1 - volatility * Math.Sqrt(pdaystomate); if (type == Entities.OptionType.Call) { return((-1 * (temp * NormalDistributionDensity(d1) * volatility) / (2 * Math.Sqrt(pdaystomate)) + risk_free * temp * NormalDistribution(d1) - risk_free * strike * temp * NormalDistribution(d2)) / Quant.YearLength); } else if (type == Entities.OptionType.Put) { return((-1 * (temp * NormalDistributionDensity(d1) * volatility) / (2 * Math.Sqrt(pdaystomate)) - risk_free * temp * NormalDistribution(-1 * d1) + risk_free * strike * temp * NormalDistribution(-1 * d2)) / Quant.YearLength); } else { return(0); } }