@@ -0,0 +1,1053 @@
+public class blackScholes%7B%0A%0A%09public double d1 = 0;%0A%09public double d2 = 0;%0A%09public double c = 0;%0A%09public double p = 0;%0A%09%0A%0A%09public blackScholes(double S0, double K, double T, double r, double sigma, double step)%7B%0A%09%09d1 = getD1(S0, K, T, r, sigma);%0A%09%09d2 = getD2(d1, sigma, T);%0A%09%09double Nd1 = getCDF(d1, step);%0A%09%09double Nd2 = getCDF(d2, step);%0A%09%09double NMd2 = getCDF(-d2, step);%0A%09%09double NMd1 = getCDF(-d1, step);%0A%09%09c = S0 * Nd1 - Nd2 * K * Math.exp(-r * T);%0A%09%09p = K * NMd2 * Math.exp(-r * T) - S0 * NMd1;%0A%09%7D%0A%0A%09public double getD1()%7B%0A%09%09return d1;%0A%09%7D%0A%0A%09public double getD2()%7B%0A%09%09return d2;%0A%09%7D%0A%0A%09public double getC()%7B%0A%09%09return c;%0A%09%7D%0A%0A%09public double getP()%7B%0A%09%09return p;%0A%09%7D%0A%0A%09public static double getCDF(double d, double step)%7B%0A%09%09CDF N = new CDF(d, true, step);%0A%09%09return N.getValue();%0A%09%7D%0A%0A%09public static double getD1(double S0, double K, double T, double r, double sigma)%7B%0A%09%09return (Math.log(S0/K) + T * (r + (sigma*sigma)/2))/(sigma*Math.sqrt(T));%0A%09%7D%0A%0A%09public static double getD2(double D1, double sigma, double T)%7B%0A%09%09return (D1 - (sigma * Math.sqrt(T)));%0A%09%7D%0A%0A%7D%0A

Create blackScholes.java