示例#1
0
        /// <summary>
        /// Gets the put option value.
        /// </summary>
        /// <param name="floatRate"></param>
        /// <param name="strikeRate"></param>
        /// <param name="volatility"></param>
        /// <param name="timeToExpiry"></param>
        /// <returns></returns>
        public static Decimal GetPutOptionValue(Decimal floatRate, Decimal strikeRate, Decimal volatility, Decimal timeToExpiry)
        {
            var dFloatRate    = Convert.ToDouble(floatRate);
            var dStrikeRate   = Convert.ToDouble(strikeRate);
            var dVolatility   = Convert.ToDouble(volatility);
            var dTimeToExpiry = Convert.ToDouble(timeToExpiry);
            var model         = new BlackScholesMertonModel(false, dFloatRate, dStrikeRate, dVolatility, dTimeToExpiry);

            return(Convert.ToDecimal(model.Value));
        }
示例#2
0
        /// <summary>
        /// Standard (Black-Scholes) option valuation
        /// r = Continuously compounded interest rate between now and time t.
        /// Discount factor is exp(-r * t).
        /// </summary>
        /// <param name="callFlag">The call/put flag.</param>
        /// <param name="fwdPrice">Price fixed today for purchase of asset at time t</param>
        /// <param name="strike">Exercise price of option</param>
        /// <param name="vol">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 reuslts for Black Scholes.</returns>
        public static object[,] Greeks(Boolean callFlag, double fwdPrice, double strike, double vol, double t)
        {
            BlackScholesMertonModel model = new BlackScholesMertonModel(callFlag, fwdPrice, strike, vol, t);

            object[,] result = new object[2, 6];
            result[0, 0]     = "Value";
            result[1, 0]     = model.Value;
            result[0, 1]     = "Delta";
            result[1, 1]     = model.SpotDelta;
            result[0, 2]     = "Gamma";
            result[1, 2]     = model.Gamma;
            result[0, 3]     = "Vega";
            result[1, 3]     = model.Vega;
            result[0, 4]     = "Theta";
            result[1, 4]     = model.Theta;
            result[0, 5]     = "Rho";
            result[1, 5]     = model.Rho;
            return(result);
        }
示例#3
0
        /// <summary>
        /// Gets the swaption value.
        /// </summary>
        /// <param name="rate"></param>
        /// <param name="strikeRate"></param>
        /// <param name="volatility"></param>
        /// <param name="timeToExpiry"></param>
        /// <returns></returns>
        public static double GetSwaptionValue(double rate, double strikeRate, double volatility, double timeToExpiry)
        {
            var model = new BlackScholesMertonModel(true, rate, strikeRate, volatility, timeToExpiry);

            return(model.Value);
        }