Esempio n. 1
0
        public void TestAmVega()
        {
            var stock = TestDataHelper.GetStock("ANZ");

            Assert.AreEqual("ANZ", stock.Name);
            var stockObject = TestHelper.CreateStock(stock);
            var fwd         = new ForwardExpiry(DateTime.Parse("23-12-2010"), 2220);
            var str         = new Strike(2100, null, null, Units.Cents);
            var vp          = new VolatilityPoint {
                Value = 0.30M
            };

            str.SetVolatility(vp);
            fwd.AddStrike(str, true);
            stockObject.VolatilitySurface.AddExpiry(fwd);
            foreach (ForwardExpiry fwdExp in stockObject.VolatilitySurface.Expiries)
            {
                foreach (Strike strike in fwdExp.Strikes)
                {
                    if ((strike.StrikePrice == 2100.0) && (fwdExp.ExpiryDate == DateTime.Parse("23-12-2010")))
                    {
                        AmOptionAnalytics call      = new AmOptionAnalytics(stockObject.Date, fwdExp.ExpiryDate, Convert.ToDouble(stockObject.Spot), strike.StrikePrice, Convert.ToDouble(strike.Volatility.Value), "A", "C", stockObject.RateCurve, stockObject.Dividends, 20);
                        double            callprice = call.Price();
                        Assert.AreEqual(callprice, 338.8661, 0.5);
                        call.MakeVega();
                        Assert.AreEqual(call.Vega, 9.093, 0.02);
                        AmOptionAnalytics put      = new AmOptionAnalytics(stockObject.Date, fwdExp.ExpiryDate, Convert.ToDouble(stockObject.Spot), strike.StrikePrice, Convert.ToDouble(strike.Volatility.Value), "A", "P", stockObject.RateCurve, stockObject.Dividends, 20);
                        double            putprice = put.Price();
                        Assert.AreEqual(putprice, 239.6014, 0.5);
                        put.MakeVega();
                        Assert.AreEqual(put.Vega, 9.093, 0.02);
                    }
                }
            }
        }
Esempio n. 2
0
        public void TestVega()
        {
            DateTime date0    = DateTime.Today;
            DateTime exp      = date0.AddDays(90);
            DateTime ex       = date0.AddDays(20);
            double   spot     = 100;
            double   strike   = 100;
            double   vol      = 0.50;
            string   paystyle = "C";
            string   exercise = "E";

            DateTime[]      dates = { date0, exp };
            double[]        rates = { 0.05, 0.05 };
            RateCurve       rc    = new RateCurve("AUD", "Continuous", date0, dates, rates);
            List <Dividend> divs  = new List <Dividend> {
                new Dividend(ex, 20)
            };
            AmOptionAnalytics utils = new AmOptionAnalytics(date0, exp, spot, strike, vol, exercise, paystyle, rc, divs, 120);
            double            pr    = Math.Round(utils.Price(), 7);

            utils.MakeVega();
            double vega = Math.Round(utils.Vega, 7);

            Assert.AreEqual(0.1223754, vega);
        }