예제 #1
0
        /// <summary>
        /// Creates a test vol surface to test temporal and strike volatility interpolation
        /// </summary>
        /// <returns></returns>
        public IVolatilitySurface CreateTestVolSurface()
        {
            IVolatilitySurface volSurface = new VolatilitySurface("BHP", 4500M, DateTime.Today);
            ForwardExpiry      expiry1    = new ForwardExpiry(DateTime.Parse("01-Jan-2010"), 4200);
            ForwardExpiry      expiry2    = new ForwardExpiry(DateTime.Parse("01-Jan-2011"), 4400);
            OptionPosition     call1      = new OptionPosition("1245", 104, PositionType.Call);
            OptionPosition     put1       = new OptionPosition("1246", 1200, PositionType.Put);
            OptionPosition     call2      = new OptionPosition("1645", 180, PositionType.Call);
            OptionPosition     put2       = new OptionPosition("1646", 1300, PositionType.Put);
            Strike             strike1    = new Strike(4200, call1, put1);
            Strike             strike2    = new Strike(4000, call2, put2);
            IVolatilityPoint   point1     = new VolatilityPoint();

            point1.SetVolatility(0.30M, VolatilityState.Default());
            put1.SetVolatility(point1);
            call1.SetVolatility(point1);
            IVolatilityPoint point2 = new VolatilityPoint();

            point2.SetVolatility(0.40M, VolatilityState.Default());
            call2.SetVolatility(point2);
            put2.SetVolatility(point2);
            expiry1.AddStrike(strike1, true);
            expiry2.AddStrike(strike2, true);
            volSurface.AddExpiry(expiry1);
            volSurface.AddExpiry(expiry2);
            return(volSurface);
        }
예제 #2
0
        /// <summary>
        /// Creates a null volatility surface to be used in extrapolation tests that utilise
        /// the historical volatility ratio
        /// </summary>
        /// <returns></returns>
        public IVolatilitySurface CreateNullVolSurface()
        {
            IVolatilitySurface volSurface = new VolatilitySurface("BHP", 4500M, DateTime.Today);
            ForwardExpiry      expiry0    = new ForwardExpiry(DateTime.Parse("14-9-2009"), 4700);
            ForwardExpiry      expiry1    = new ForwardExpiry(DateTime.Parse("16-9-2009"), 4700);
            ForwardExpiry      expiry2    = new ForwardExpiry(DateTime.Parse("30-9-2009"), 4750);
            OptionPosition     call0      = new OptionPosition("1145", 104, PositionType.Call);
            OptionPosition     put0       = new OptionPosition("1146", 1200, PositionType.Put);
            OptionPosition     call1      = new OptionPosition("1245", 104, PositionType.Call);
            OptionPosition     put1       = new OptionPosition("1246", 1200, PositionType.Put);
            OptionPosition     call2      = new OptionPosition("1645", 180, PositionType.Call);
            OptionPosition     put2       = new OptionPosition("1646", 1300, PositionType.Put);
            Strike             strike0    = new Strike(1.00, 4599, call0, put0);
            Strike             strike1    = new Strike(0.867, 4700, call1, put1);
            Strike             strike2    = new Strike(1.00, 4750, call2, put2);
            Strike             strike3    = new Strike(1.2, 4750, call2, put2);
            Strike             strike4    = new Strike(0.30, 4750, call2, put2);
            IVolatilityPoint   point0     = new VolatilityPoint();

            point0.SetVolatility(0.00M, VolatilityState.Default());
            put0.SetVolatility(point0);
            call0.SetVolatility(point0);
            strike0.SetVolatility(point0);
            IVolatilityPoint point1 = new VolatilityPoint();

            point1.SetVolatility(0.00M, VolatilityState.Default());
            put1.SetVolatility(point1);
            call1.SetVolatility(point1);
            strike1.SetVolatility(point1);
            IVolatilityPoint point2 = new VolatilityPoint();

            point2.SetVolatility(0.00M, VolatilityState.Default());
            strike2.SetVolatility(point2);
            call2.SetVolatility(point2);
            put2.SetVolatility(point2);
            IVolatilityPoint point3 = new VolatilityPoint();

            point3.SetVolatility(0.00M, VolatilityState.Default());
            strike3.SetVolatility(point3);
            IVolatilityPoint point4 = new VolatilityPoint();

            point4.SetVolatility(0.00M, VolatilityState.Default());
            strike4.SetVolatility(point4);
            expiry0.AddStrike(strike0, true);
            expiry1.AddStrike(strike1, true);
            expiry2.AddStrike(strike2, true);
            expiry2.AddStrike(strike3, true);
            expiry2.AddStrike(strike4, true);
            volSurface.AddExpiry(expiry0);
            volSurface.AddExpiry(expiry1);
            volSurface.AddExpiry(expiry2);
            return(volSurface);
        }