Пример #1
0
        public void MakeDeltaGamma(Tree spotT, Pricer priceT, ZeroCurve myZero, DivList myDiv)
        {
            SetParam(spotT, priceT);
            Tree treeD = new Tree
            {
                GridSteps = GridSteps + 2,
                Spot      = Spot,
                Sig       = Sigma,
                Tau       = Tau * (1 + 2 / GridSteps)
            };

            treeD.MakeGrid(myZero, myDiv);
            priceT.MakeGrid(treeD);
            double[] s = new double[3];
            double[] c = new double[3];
            for (int i = 0; i <= 2; ++i)
            {
                s[i] = treeD.GetSpotMatrix(2, i);
                c[i] = priceT.GetPriceMatrix(2, i);
            }
            Delta = (s[0] * (2 * s[1] - s[0]) * (c[1] - c[2]) +
                     (s[1] * s[1]) * (c[2] - c[0]) + s[2] * (2 * s[1] - s[2]) * (c[0] - c[1]))
                    / (s[1] - s[0]) / (s[2] - s[0]) / (s[2] - s[1]);

            Gamma = 2 * (s[0] * (c[1] - c[2]) + s[1] * (c[2] - c[0]) + s[2] * (c[0] - c[1]))
                    / (s[1] - s[0]) / (s[2] - s[0]) / (s[2] - s[1]);
        }
Пример #2
0
        public void MakeVega(Tree spotT, Pricer priceT, ZeroCurve myZero, DivList myDiv)
        {
            SetParam(spotT, priceT);
            Tree t1 = new Tree(), t2 = new Tree();

            t1.Tau       = Tau;
            t1.GridSteps = GridSteps;
            t1.Sig       = .99 * Sigma;
            t1.Spot      = Spot;
            t1.MakeGrid(myZero, myDiv);
            priceT.MakeGrid(t1);
            double p1 = priceT.Price();

            t2.Tau       = Tau;
            t2.GridSteps = GridSteps;
            t2.Sig       = 1.01 * Sigma;
            t2.Spot      = Spot;
            t2.MakeGrid(myZero, myDiv);
            priceT.MakeGrid(t2);
            double p2 = priceT.Price();

            if (Sigma != 0)
            {
                Vega = 0.01 * (p2 - p1) / (2 * 0.01 * Sigma);
            }
        }
Пример #3
0
 private void SetParam(Tree spotT, Pricer priceT)
 {
     if ((spotT != null) && (priceT != null))
     {
         GridSteps = spotT.GridSteps;
         Tau       = spotT.Tau;
         Sigma     = spotT.Sig;
         Spot      = spotT.Spot;
         Strike    = priceT.Strike;
         Style     = priceT.Style;
         Payoff    = priceT.Payoff;
         Smoothing = priceT.Smoothing;
     }
 }
Пример #4
0
        public static double FindPrice(ZeroCurve myZero, DivList myDiv, OrcWingVol myVol, double t,
                                       double strike, double spot, string style, string paystyle, double gridsteps)
        {
            //get the atfwd
            double atFwd = GetATMfwd(myZero, myDiv, spot, t);
            //set up the tree
            var myTree       = new Tree();
            int numGridSteps = (gridsteps < 20.0) ? 20 : Convert.ToInt32(gridsteps);

            myTree.GridSteps = numGridSteps;
            myTree.Tau       = t;
            myTree.Sig       = myVol.orcvol(atFwd, strike);
            myTree.Spot      = spot;
            myTree.MakeGrid(myZero, myDiv);
            //create pricer
            var myPrice = new Pricer {
                Strike = strike, Payoff = paystyle, Smoothing = "y", Style = style
            };

            myPrice.MakeGrid(myTree);
            double pr = myPrice.Price();

            return(pr);
        }
Пример #5
0
        public void MakeTheta(Tree spotT, Pricer priceT, ZeroCurve myZero, DivList myDiv)
        {
            SetParam(spotT, priceT);
            Tree t1 = new Tree(), t2 = new Tree();

            t1.Tau       = Tau;
            t1.GridSteps = GridSteps;
            t1.Sig       = Sigma;
            t1.Spot      = Spot;
            t1.MakeGrid(myZero, myDiv);
            priceT.MakeGrid(t1);
            double p1 = priceT.Price();
            double t  = Tau - 1.00 / 365.00;

            t2.Tau       = t;
            t2.GridSteps = GridSteps;
            t2.Sig       = Sigma;
            t2.Spot      = Spot;
            t2.MakeGrid(myZero, myDiv);
            priceT.MakeGrid(t2);
            double p2 = priceT.Price();

            Theta = (p2 - p1);
        }