Esempio n. 1
0
    static void option()
    {
        BinomialOption p = new BinomialOption(100, 1, 0.07, 0.02, 0.2);

        p.print();
        double s0      = 88;
        double t0      = 0;
        double Vtarget = 18;
        double Vtol    = 0.01;

        p.Valuation(s0, t0);
        p.impliedVolatility(s0, t0, Vtarget, Vtol);
    }
Esempio n. 2
0
    static void Main()
    {
        //bool OptionType = true; //true is call, false is put
        bool   OptionKind              = true; //true is american, false is european
        double Strike                  = 90;
        double S0                      = 88;   //underlying
        double ExpireTime              = 10;
        double t0                      = 0;
        int    n                       = 5;
        double RiskFreeRate            = 0.02;
        double ContinuousDividendYield = 0.0;
        double Volatility              = 0.2;
        double Vtarget                 = 18;
        double Vtol                    = 0.01;

        BinomialOption p = new BinomialOption(false, OptionKind, Strike, ExpireTime, RiskFreeRate, ContinuousDividendYield, Volatility);
        BinomialOption c = new BinomialOption(true, OptionKind, Strike, ExpireTime, RiskFreeRate, ContinuousDividendYield, Volatility);

        //put call parity
        Console.WriteLine("Put Call Parity Check");
        Console.WriteLine("C+Ke^(-rt): " + (c.Valuation(S0, t0, n) + (Strike * (Math.Exp(-RiskFreeRate * ExpireTime)))));
        Console.WriteLine("P + S0: " + (p.Valuation(S0, t0, n) + S0));

        Console.WriteLine(" ");
        Console.WriteLine("The Put option value is:" + p.Valuation(S0, t0, n));
        Console.WriteLine("The Delta is:" + p.Del(S0, t0, n));
        Console.WriteLine("The Gamma is:" + p.Gam(S0, t0, n));
        Console.WriteLine("The Veg is:" + p.Veg(S0, t0, n));
        Console.WriteLine("The Theta is:" + p.Thet(S0, t0, n));
        Console.WriteLine("The Rho is:" + p.Rhoo(S0, t0, n));
        Console.WriteLine("The implied volatility is : " + p.impliedVolatility(S0, t0, Vtarget, Vtol, n));


        Console.WriteLine(" ");
        Console.WriteLine("The Call option value is:" + c.Valuation(S0, t0, n));
        Console.WriteLine("The Delta is:" + c.Del(S0, t0, n));
        Console.WriteLine("The Gamma is:" + c.Gam(S0, t0, n));
        Console.WriteLine("The Veg is:" + c.Veg(S0, t0, n));
        Console.WriteLine("The Theta is:" + c.Thet(S0, t0, n));
        Console.WriteLine("The Rho is:" + c.Rhoo(S0, t0, n));
        Console.WriteLine("The implied volatility is : " + c.impliedVolatility(S0, t0, Vtarget, Vtol, n));
    }