Ejemplo n.º 1
0
        public void BinRelativeLongDated()
        {
            double _spot   = 26.4;
            double _strike = 40.0;

            double[]           _rt = { 0.0531835066,
                                       0.0533209825,
                                       0.0505847905,
                                       0.0476071704,
                                       0.0462601791,
                                       0.0413960339,
                                       0.0395067537,
                                       0.0391989121,
                                       0.0397679692,
                                       0.0409565679,
                                       0.0424276371,
                                       0.0436165574,
                                       0.0447919141,
                                       0.0459378964,
                                       0.047129656,
                                       0.0483301138,
                                       0.0490433005,
                                       0.049747259,
                                       0.0504720079,
                                       0.051218 };
            int[]              _rtdays = { 3,   33,   66,  95, 119, 210,
                                           301,             392,  483,
                                           574,             665,  733, 825, 914,
                                           1006,           1098, 1190,
                                           1280,           1372, 1466 };
            int[]              _dvdays    = { 101, 297, 465, 661, 829, 1025, 1193, 1389 };
            double[]           _dd        = { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };
            double             _vol       = 0.50;
            DateTime           _today     = new DateTime(2008, 11, 14);
            DateTime           _expiry    = new DateTime(2012, 05, 17);
            int                _steps     = 120;
            string             _style     = "American";
            double             _tau       = _expiry.Subtract(_today).Days / 365.0;
            string             _smoothing = "N";
            BinomialTreePricer lhs        = new BinomialTreePricer(_spot, _strike, false, _tau, _vol, _steps, true, _style, _smoothing, _rtdays, _rt, _dvdays, _dd, typeof(EquityDiscreteDivTree));
            double             price      = lhs.GetPrice();
            double             delta      = lhs.GetDelta();
            double             gamma      = lhs.GetGamma();
            double             vega       = lhs.GetVega();
            double             theta      = lhs.GetTheta();

            //Price
            Assert.AreEqual(7.20339, price, 0.001);
            //Delta
            Assert.AreEqual(0.5685058, delta, 0.001);
            //Gamma
            Assert.AreEqual(0.0162134, gamma, 0.001);
            //Vega
            Assert.AreEqual(0.191464, vega, 0.001);
            //Theta
            Assert.AreEqual(-0.0048253, theta, 0.001);
        }
Ejemplo n.º 2
0
        public void TestBinomialRelativeCall()
        {
            SetUpExampleOption1();
            BinomialTreePricer lhs   = new BinomialTreePricer(spot, strike, false, tau, vol, steps, true, style, smoothing, rtdays, rtamts, divdays, dd, typeof(EquityPropDivTree));
            double             price = lhs.GetPrice();
            double             delta = lhs.GetDelta();
            double             gamma = lhs.GetGamma();
            double             vega  = lhs.GetVega();
            double             theta = lhs.GetTheta();

            Assert.AreEqual(19.19592, price, 0.0001);
            Assert.AreEqual(0.59397, delta, 0.0001);
            Assert.AreEqual(0.00832, gamma, 0.0001);
            Assert.AreEqual(0.36613, vega, 0.0001);
            Assert.AreEqual(-0.02997, theta, 0.0001);
        }
Ejemplo n.º 3
0
        public void TestBinomialRelativePut()
        {
            SetUpExampleOption1();
            BinomialTreePricer lhs   = new BinomialTreePricer(spot, strike, true, tau, vol, steps, true, style, smoothing, rtdays, rtamts, divdays, dd, typeof(EquityPropDivTree));
            double             price = lhs.GetPrice();
            double             delta = lhs.GetDelta();
            double             gamma = lhs.GetGamma();
            double             vega  = lhs.GetVega();
            double             theta = lhs.GetTheta();

            Assert.AreEqual(20.79427, price, 0.0001);
            Assert.AreEqual(-0.4023769, delta, 0.0001);
            Assert.AreEqual(0.00721022, gamma, 0.0001);
            Assert.AreEqual(0.35311, vega, 0.0001);
            Assert.AreEqual(-0.0155038, theta, 0.0001);
        }
Ejemplo n.º 4
0
        public void DiscreteDivAtExpiry()
        {
            double _spot   = 385.5;
            double _strike = 400;

            double[] _rt = { 0.0425,
                             0.0452,
                             0.0457,
                             0.0462 };
            int[]    _rtdays = { 1, 32, 63, 93 };
            int[]    _dvdays = { 0, 48 };
            double[] _divs   = { 20, 10 };
            double   _vol    = 0.2046;

            DateTime _today  = new DateTime(2010, 05, 07);
            DateTime _expiry = new DateTime(2010, 06, 24);
            double   _tau    = _expiry.Subtract(_today).Days / 365.0;

            int    _steps     = 120;
            string _style     = "American";
            string _smoothing = "N";

            BinomialTreePricer lhs = new BinomialTreePricer(_spot, _strike, true, _tau, _vol, _steps, true, _style, _smoothing, _rtdays, _rt, _dvdays, _divs, typeof(EquityPropDivTree));

            double price = lhs.GetPrice();
            double delta = lhs.GetDelta();
            double gamma = lhs.GetGamma();
            double vega  = lhs.GetVega();
            double theta = lhs.GetTheta();

            //Price
            Assert.AreEqual(25.7028, price, 0.001);
            //Delta
            Assert.AreEqual(-0.74884, delta, 0.001);
            //Gamma
            Assert.AreEqual(0.01041, gamma, 0.001);
            //Vega
            Assert.AreEqual(0.42628, vega, 0.001);
            //Theta
            Assert.AreEqual(-0.0512, theta, 0.001);
        }