Exemplo n.º 1
0
 public double[,,] output(double S0, double K, double vol, double T, int N, double r, double del, bool type, bool optiontype)
 {
     double[,] underlyvalues = GetValues.UnderlyingValues.underlyingvalues(S0, K, vol, T, N, r, del, type, optiontype);
     double[,] intrinsic     = GetValues.IntriValues.intrinsicvalues(S0, K, vol, T, N, r, del, type, optiontype);
     double[,] American      = GetValues.American.amer(S0, K, vol, T, N, r, del, type, optiontype);
     double[,] Option        = GetValues.OptionPrice.optionprice(S0, K, vol, T, N, r, del, type, optiontype);
     double[,,] a            = OutputValues.readdata(underlyvalues, intrinsic, American, Option, 4);
     return(a);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            OutputValues a = new OutputValues();

            Console.WriteLine("Enter S0: (double)");
            double S0 = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter K: (double)");
            double K = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter vol: (double)");
            double vol = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter T: (double)");
            double T = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter N: (int)");
            int N = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter r: (double)");
            double r = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter dividend: (double)");
            double dividend = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter type(call true, put false): (bool)");
            bool type = Convert.ToBoolean(Console.ReadLine());

            Console.WriteLine("Enter optiontype(Eur true, Ame false): (bool)");
            bool optiontype = Convert.ToBoolean(Console.ReadLine());

            //You can also choice to outprint all related data
            //Console.WriteLine("Underlying price:");
            //double[,,] c = a.output(S0, K, vol, T, N, r, dividend, type, optiontype);
            //PrintResults(c, 0);//underlying price
            //Console.WriteLine("Intrinsic price:");
            //PrintResults(c, 1);//Intrinsic price
            //Console.WriteLine("American price:");
            //PrintResults(c, 2);//American price
            //Console.WriteLine("Option price:");
            //PrintResults(c, 3);//all Option price
            Console.Write("Option price: ");
            double[,] op = GetValues.OptionPrice.optionprice(S0, K, vol, T, N, r, dividend, type, optiontype);
            Console.Write(op[0, N] + "\n");          //option price
            double[] greek = GreekValues.output(S0, K, vol, T, N, r, dividend, type, optiontype, 0.001, 0.001);
            Console.WriteLine("Delta: " + greek[0]); //delta
            Console.WriteLine("Gamma: " + greek[1]); //gamma
            Console.WriteLine("Vega: " + greek[2]);  //vega
            Console.WriteLine("Theta: " + greek[3]); //theta
            Console.WriteLine("Rho: " + greek[4]);   //rho
            Console.ReadLine();
        }