예제 #1
0
        public double EuropeanOption(string CallOrPut, double S, double K, double v, double r, double T, double q)
        {
            double retValue;
            double d1;
            double d2;
            double nd1;
            double nd2;
            double nnd1;
            double nnd2;

            d1   = (Math.Log(S / K) + (r - q + 0.5 * Math.Pow(v, 2)) * T) / (double)(v * Math.Sqrt(T));
            d2   = (Math.Log(S / (double)K) + (r - q - 0.5 * Math.Pow(v, 2)) * T) / (double)(v * Math.Sqrt(T));
            nd1  = NormsDistribution.N(d1);
            nd2  = NormsDistribution.N(d2);
            nnd1 = NormsDistribution.N(-d1);
            nnd2 = NormsDistribution.N(-d2);

            if (CallOrPut == "CE")
            {
                retValue = S * Math.Exp(-q * T) * nd1 - K * Math.Exp(-r * T) * nd2;
            }
            else
            {
                retValue = -S *Math.Exp(-q *T) * nnd1 + K * Math.Exp(-r * T) * nnd2;
            }

            return(retValue);
        }
예제 #2
0
        //public void OptionPrice(object OptionType, object S, object X, object T, object r, object v, object d)
        //{
        //    if (OptionType == "Call")
        //        OptionPrice = Exp(-d * T) * S * Application.NormSDist(dOne(S, X, T, r, v, d)) - X * Exp(-r * T) * Application.NormSDist(dOne(S, X, T, r, v, d) - v * Sqr(T));
        //    else if (OptionType == "Put")
        //        OptionPrice = X * Exp(-r * T) * Application.NormSDist(-dTwo(S, X, T, r, v, d)) - Exp(-d * T) * S * Application.NormSDist(-dOne(S, X, T, r, v, d));
        //}

        public double OptionDelta(string OptionType, double S, double X, double r, double T, double v, double d)
        {
            double retValue = 0;

            if (OptionType.ToString() == "CE")
            {
                retValue = NormsDistribution.N(dOne(S, X, T, r, v, d));
            }
            else if (OptionType.ToString() == "PE")
            {
                retValue = NormsDistribution.N(dOne(S, X, T, r, v, d)) - 1;
            }

            return(Math.Round(retValue, 2));
        }
예제 #3
0
 public double NdTwo(double S, double X, double T, double r, double v, double d)
 {
     return(NormsDistribution.N(dTwo(S, X, T, r, v, d)));
 }