/// <summary> /// /// </summary> /// <param name="fwd"></param> /// <param name="tau1"></param> /// <param name="strike1"></param> /// <param name="rate1"></param> /// <param name="sigma1"></param> /// <param name="payoff"></param> /// <returns></returns> public double BSprice(double fwd, double tau1, double strike1, double rate1, double sigma1, string payoff) { int s1; if ((payoff.ToLower() == "p") | (payoff.ToLower() == "put")) { s1 = -1; } else { s1 = 1; } double d1 = (Math.Log(fwd / strike1) + 0.5 * sigma1 * sigma1 * tau1) / sigma1 / Math.Pow(tau1, 0.5); double d2 = d1 - sigma1 * Math.Pow(tau1, 0.5); double n1 = BasicMath.CND(s1 * d1); double n2 = BasicMath.CND(s1 * d2); return(s1 * (fwd * n1 - strike1 * n2) * Math.Exp(-rate1 * tau1)); }