Пример #1
0
        /// <summary>
        /// Values at, overriding calibrated Wing Model with supplied parms
        /// </summary>
        /// <param name="stock"></param>
        /// <param name="expiry">The expiry.</param>
        /// <param name="strikes">The strikes.</param>
        /// <param name="parms">The parms.</param>
        /// <param name="oride"></param>
        /// <param name="cache">if set to <c>true</c> [cache].</param>
        /// <returns></returns>
        public ForwardExpiry ValueAt(Stock stock, DateTime expiry, List <Double> strikes, OrcWingParameters parms, bool oride, bool cache)
        {
            var fwdExpiry = new ForwardExpiry {
                ExpiryDate = expiry
            };
            double forward = stock.GetForward(stock.Date, expiry);

            fwdExpiry.FwdPrice = Convert.ToDecimal(forward);
            foreach (double strike in strikes)
            {
                double           val = OrcWingVol.Value(strike, parms);
                IVolatilityPoint vp  = new VolatilityPoint();
                vp.SetVolatility(Convert.ToDecimal(val), VolatilityState.Default());
                bool   node = VolatilitySurfaceHelper.IsMatch(strike, expiry, NodalExpiries);
                Strike newstrike;
                if (node & oride)
                {
                    newstrike = VolatilitySurfaceHelper.GetStrike(strike, expiry, NodalExpiries);
                    //new data points, derefernce fitting model
                    newstrike.InterpModel = null;
                }
                else
                {
                    //var wingModel = new WingInterp {WingParams = parms};
                    newstrike = new Strike {
                        StrikePrice = strike, InterpModel = null
                    };
                    //newstrike.InterpModel = wingModel;
                    fwdExpiry.AddStrike(newstrike, node);
                }
                newstrike.SetVolatility(vp);
            }
            return(fwdExpiry);
        }
Пример #2
0
        /// <summary>
        /// Values at.
        /// </summary>
        /// <param name="stock"></param>
        /// <param name="expiries">The expiries.</param>
        /// <param name="strikes">The strikes.</param>
        /// <param name="?">Cache to vol object</param>
        /// <param name="cache"></param>
        /// <returns></returns>
        public List <ForwardExpiry> ValueAt(Stock stock, List <DateTime> expiries, List <Double> strikes, bool cache)
        {
            var forwardExpiries = new List <ForwardExpiry>();

            foreach (DateTime exp in expiries)
            {
                var fwdExpiry = new ForwardExpiry();
                foreach (double str in strikes)
                {
                    var    wingModel = new WingInterp();
                    double forward   = stock.GetForward(stock.Date, exp.Date);
                    double spot      = Convert.ToDouble(stock.Spot);
                    fwdExpiry.FwdPrice = Convert.ToDecimal(forward);
                    double y     = str;
                    double x     = (exp.Subtract(Date)).Days / 365.0;
                    IPoint point = new Point2D(x, y);
                    InterpCurve.Forward = forward;
                    InterpCurve.Spot    = spot;
                    var val             = InterpCurve.Value(point);
                    IVolatilityPoint vp = new VolatilityPoint();
                    vp.SetVolatility(Convert.ToDecimal(val), VolatilityState.Default());
                    fwdExpiry.ExpiryDate = exp;
                    bool node = VolatilitySurfaceHelper.IsMatch(str, exp, NodalExpiries);
                    // copy model used to return ForwardExpiry object
                    var newstrike = new Strike {
                        StrikePrice = str
                    };
                    var wing = (WingModelInterpolation)InterpCurve.GetYAxisInterpolatingFunction();
                    //SABRModelInterpolation wing = (SABRModelInterpolation)_interpCurve.GetYAxisInterpolatingFunction();
                    wingModel.WingParams  = wing.WingParameters;
                    newstrike.InterpModel = wingModel;
                    fwdExpiry.AddStrike(newstrike, node);

                    newstrike.SetVolatility(vp);
                }
                forwardExpiries.Add(fwdExpiry);
            }
            return(forwardExpiries);
        }
Пример #3
0
        public void TestPricevsORCExample()
        {
            DateTime[] rtDates = { DateTime.Parse("17-Aug-2010"),
                                   DateTime.Parse("17-Sep-2010"),
                                   DateTime.Parse("18-Oct-2010"),
                                   DateTime.Parse("17-Nov-2010"),
                                   DateTime.Parse("10-Dec-2010") };

            double[]  rates = { 0.045507232,
                                0.046609656,
                                0.047336042,
                                0.047655159,
                                0.047737236 };
            RateCurve rc = new RateCurve("AUD", "Semi-Annual", DateTime.Parse("16-Aug-2010"), rtDates, rates);
            //Dividend d1 = new Dividend(DateTime.Parse("16-8-2010"),  11.745786M);
            Dividend        d2       = new Dividend(DateTime.Parse("17-8-2010"), 0.893295M);
            Dividend        d3       = new Dividend(DateTime.Parse("23-8-2010"), 7.856689M);
            Dividend        d4       = new Dividend(DateTime.Parse("24-8-2010"), 2.898251M);
            Dividend        d5       = new Dividend(DateTime.Parse("25-8-2010"), 3.344721M);
            Dividend        d6       = new Dividend(DateTime.Parse("26-8-2010"), 0.485070M);
            Dividend        d7       = new Dividend(DateTime.Parse("27-8-2010"), 0.835305M);
            Dividend        d8       = new Dividend(DateTime.Parse("30-8-2010"), 3.952976M);
            Dividend        d9       = new Dividend(DateTime.Parse("31-8-2010"), 0.884255M);
            Dividend        d10      = new Dividend(DateTime.Parse("1-9-2010"), 2.013798M);
            Dividend        d11      = new Dividend(DateTime.Parse("2-9-2010"), 1.241407M);
            Dividend        d12      = new Dividend(DateTime.Parse("3-9-2010"), 0.613699M);
            Dividend        d13      = new Dividend(DateTime.Parse("6-9-2010"), 11.712946M);
            Dividend        d14      = new Dividend(DateTime.Parse("7-9-2010"), 3.775104M);
            Dividend        d15      = new Dividend(DateTime.Parse("8-9-2010"), 0.606597M);
            Dividend        d16      = new Dividend(DateTime.Parse("9-9-2010"), 0.268093M);
            Dividend        d17      = new Dividend(DateTime.Parse("10-9-2010"), 0.144851M);
            Dividend        d18      = new Dividend(DateTime.Parse("13-9-2010"), 1.600975M);
            Dividend        d19      = new Dividend(DateTime.Parse("14-9-2010"), 1.499946M);
            Dividend        d20      = new Dividend(DateTime.Parse("15-9-2010"), 0.238824M);
            Dividend        d21      = new Dividend(DateTime.Parse("16-9-2010"), 0.117931M);
            List <Dividend> divCurve = new List <Dividend>()
            {
                d2, d3, d4, d5, d6, d7, d8, d9, d10,
                d11, d12, d13, d14, d15, d16, d17, d18, d19, d20, d21
            };
            DateTime date0 = new DateTime(2010, 08, 16);
            DateTime exp   = new DateTime(2010, 9, 16);
            double   spot  = 4447.62;
            //double future = 4420;
            double strike      = 4200;
            string stockId     = "XJO_Spot";
            Stock  stock       = new Stock(date0, Convert.ToDecimal(spot), stockId, "XJO", rc, divCurve);
            double fwd         = stock.GetForward(date0, exp);
            var    wingParams1 = new OrcWingParameters
            {
                CurrentVol = 0.234828,
                RefVol     = 0.234828,
                SlopeRef   = -0.109109,
                PutCurve   = 1.235556,
                CallCurve  = 0.60895,
                DnCutoff   = -0.493791,
                UpCutoff   = 0.506209,
                RefFwd     = 4420.092383,
                AtmForward = 4420.092383,
                Vcr        = 0,
                Scr        = 0,
                Ssr        = 100,
                Dsr        = 0.2,
                Usr        = 0.2,
            };
            VolatilitySurface vs      = new VolatilitySurface(stockId, Convert.ToDecimal(spot), date0);
            ForwardExpiry     expiry  = new ForwardExpiry(exp, Convert.ToDecimal(fwd));
            OptionPosition    op      = new OptionPosition("XJO_Vanilla_ETO_Sep10_4200.000_Put", 30.237108, PositionType.Put);
            Strike            strike0 = new Strike(strike, null, op);

            expiry.AddStrike(strike0, true);
            List <double> strikes1 = new List <double> {
                4200
            };
            ForwardExpiry forwardexpiry = vs.ValueAt(stock, exp, strikes1, wingParams1, true, false);
            double        vol           = Convert.ToDouble(forwardexpiry.Strikes[0].Volatility.Value);
            var           utils         = new AmOptionAnalytics(date0, exp, spot, strike, vol, "European", "Put", rc, divCurve, 120);
            double        pr            = Math.Round(utils.Price(), 7);
        }