コード例 #1
0
        public void SimpleOrcWingModel()
        {
            const double vc     = 0.2417;
            const double sr     = -0.1243;
            const double pc     = 0.2283;
            const double cc     = -1.1478;
            const double dc     = -0.2871;
            const double uc     = 0.1327;
            const double refFwd = 3065.0;
            const double refVol = 0.2417;
            const double vcr    = 0.0;
            const double scr    = 0.0;
            const double ssr    = 100.0;
            const double dsm    = 0.5;
            const double usm    = 0.5;
            const double time   = 0.2931507;

            OrcWingVol volSurface = new OrcWingVol();

            volSurface.currentVol     = vc;
            volSurface.dnCutoff       = dc;
            volSurface.dsr            = dsm;
            volSurface.putCurve       = pc;
            volSurface.callCurve      = cc;
            volSurface.refFwd         = refFwd;
            volSurface.refVol         = refVol;
            volSurface.scr            = scr;
            volSurface.slopeRef       = sr;
            volSurface.ssr            = ssr;
            volSurface.timeToMaturity = time;
            volSurface.upCutoff       = uc;
            volSurface.usr            = usm;
            volSurface.vcr            = vcr;

            double res1 = volSurface.orcvol(3065.0, 1508.64);
            double res2 = volSurface.orcvol(3065.0, 2222.65);
            double res3 = volSurface.orcvol(3065.0, 2591.17);
            double res4 = volSurface.orcvol(3065.0, 3224.57);
            double res5 = volSurface.orcvol(3065.0, 3454.89);
            double res6 = volSurface.orcvol(3065.0, 4502.88);

            Assert.IsTrue(res1 < 0.3147);
            Assert.IsTrue(res1 > 0.3143);

            Assert.IsTrue(res2 < 0.3040);
            Assert.IsTrue(res2 > 0.3035);

            Assert.IsTrue(res3 < 0.2692);
            Assert.IsTrue(res3 > 0.2688);

            Assert.IsTrue(res4 < 0.2325);
            Assert.IsTrue(res4 > 0.2321);

            Assert.IsTrue(res5 < 0.2105);
            Assert.IsTrue(res5 > 0.2101);

            //Test floor;
            Assert.IsTrue(res6 < 0.1909);
            Assert.IsTrue(res6 > 0.1905);
        }
コード例 #2
0
ファイル: Collar.cs プロジェクト: zhangz/Highlander.Net
        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 nGridsteps = (gridsteps < 20.0) ? 20 : Convert.ToInt32(gridsteps);

            myTree.Gridsteps = nGridsteps;
            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);
        }