コード例 #1
0
        public void TestBondOptionPrice()
        {
            var settleDate         = new Date(2008, 1, 17);                                                    // Option related
            var maturityDate       = new Date(2009, 8, 1);                                                     // Bond related
            var forwardDate        = new Date(2008, 4, 17);                                                    // Forward related
            var notional           = 1000000.0;                                                                //
            var annualCouponRate   = 0.13;                                                                     // According to JSE Bond Pricer for R153
            var couponMonth1       = 2;                                                                        //
            var couponDay1         = 28;                                                                       //
            var couponMonth2       = 8;                                                                        //
            var couponDay2         = 31;                                                                       //
            var booksCloseDateDays = 10;                                                                       //
            var zaCalendar         = new Calendar("Test");                                                     //
            var bondOptionR153     = new JSEBondOption(forwardDate, maturityDate, PutOrCall.Call, settleDate); //

            var bondForwardR153 = new JSEBondForward(forwardDate, maturityDate, notional, annualCouponRate, couponMonth1,
                                                     couponDay1, couponMonth2, couponDay2, booksCloseDateDays, zaCalendar, TestHelpers.ZAR);

            var ytm    = 0.0930; //
            var repo   = 0.1075; // See example
            var strike = 0.09;   //
            var vol    = 0.07;   //

            var results = JSEBondOptionEx.BlackOption(bondOptionR153, strike, vol, repo, bondForwardR153, ytm);

            Assert.AreEqual(103.8547113436135, (double)results.GetScalar(JSEBondOptionEx.Keys.BlackOption), 1e-8);
        }
コード例 #2
0
        // HelpTopic = "http://www.quantsa.org/")] // TODO:
        public static double FormulaBondOption([ExcelArgument(Description = "The underlying bond option.")]
                                               JSEBondOption bondOptionR153,
                                               [ExcelArgument(Description = "The strike/struck rate of the option.")]
                                               double strike,
                                               [ExcelArgument(Description = "Annualized volatility.")]
                                               double vol,
                                               [ExcelArgument(Description = "The repo rate of the deal.")]
                                               double repo,
                                               [ExcelArgument(Description = "The yield to maturity of the bond.")]
                                               double ytm,
                                               [ExcelArgument(Description = "The underlying bond forward from which the forward price is derived.")]
                                               JSEBondForward bondForward)

        {
            var bondOptionPrice = (double)JSEBondOptionEx.BlackOption(bondOptionR153, strike, vol, repo, bondForward, ytm).GetScalar(JSEBondOptionEx.Keys.BlackOption);

            return(bondOptionPrice);
        }