Exemplo n.º 1
0
        /// <summary>
        /// Standard (Black-Scholes) option valuation
        /// r = Continuously compounded interest rate between now and time t.
        /// Discount factor is exp(-r * t).
        /// Different combinations in inputs to the generalized model instantiate different models:
        /// b=r (the cost of carry rate = the risk free rate). Black Scholes 1973 stock option model.
        /// b=r-q, where q is the continuous dividend yield. Merton 1973 stock option model.
        /// b=0. The Black 1976 futures option model.
        /// b=0 and r=0. Assay 1982 margined futures option model.
        /// b=r - rf, rf being the foreign rate. Garman Kohlhagen 1983 currency option model.
        /// </summary>
        /// <param name="callFlag">The call/put flag.</param>
        /// <param name="price">The stock price S. Price fixed today for purchase of asset at time t</param>
        /// <param name="strike">The strike price K. Exercise price of option</param>
        /// <param name="rate">The risk free rate.</param>
        /// <param name="costOfCarry">The cost of carry rate.</param>
        /// <param name="vol">Volatility of the relative price change of the underlying asset S.
        /// Per cent volatility in units of (year)^(-1/2)</param>
        /// <param name="t">Time in years to the maturity of the option.</param>
        /// <returns>An array of results for Black Scholes.</returns>
        public object BSMGeneralisedWithGreeks(bool callFlag, double price, double strike,
                                               double rate, double costOfCarry, double vol, double t)
        {
            var model = BlackScholesMertonModel.BSMGeneralisedWithGreeks(callFlag, price, strike, rate, costOfCarry, vol, t);

            return(model);
        }
Exemplo n.º 2
0
        public static void RunBSMGeneralisedOptTest()
        {
            var result1 = (object[, ])BlackScholesMertonModel.BSMGeneralisedWithGreeks(false, _fwdPrice, _strike, _rate, _caRRY, _volatility, _time);

            Debug.WriteLine(String.Format("Premium : {0} Delta : {1} Gamma : {2} Vega : {3} Theta : {4} Rho : {5}", result1[1, 0], result1[1, 1], result1[1, 2], result1[1, 3], result1[1, 4], result1[1, 5]));
            Assert.AreEqual((double)result1[1, 0], 4.087d, 0.0001d);
            var result2 = (object[, ])BlackScholesMertonModel.BSMGeneralisedWithGreeks(true, -_fwdPrice, -_strike, _rate, _caRRY, -_volatility, _time);

            Debug.WriteLine(String.Format("Premium : {0} Delta : {1} Gamma : {2} Vega : {3} Theta : {4} Rho : {5}", result2[1, 0], result2[1, 1], result2[1, 2], result2[1, 3], result2[1, 4], result2[1, 5]));
            Assert.AreEqual((double)result2[1, 0], 4.087d, 0.0001d);
        }