/// <summary>
        /// Gets the price.
        /// </summary>
        /// <returns></returns>
        public double GetPrice()
        {
            double fwd  = EquityAnalytics.GetForwardCCLin365(_spot, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double rate = EquityAnalytics.GetRateCCLin365(0, _tau, _rtdays, _rtamts);

            return(BSprice(fwd, _tau, _strike, rate, _vol, _isCall));
        }
        /// <summary>
        /// Gets the vega.
        /// </summary>
        /// <returns></returns>
        public double GetVega()
        {
            double q   = EquityAnalytics.GetYieldCCLin365(_spot, 0, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double fwd = EquityAnalytics.GetForwardCCLin365(_spot, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double d1  = (Math.Log(fwd / _strike) + _vol * _vol * _tau / 2) / _vol / Math.Sqrt(_tau);
            double lhs = _spot * Math.Sqrt(_tau) * _nd.ProbabilityDensity(d1) * 0.01 * Math.Exp(-q * _tau);

            return(lhs);
        }
        /// <summary>
        /// Gets the gamma.
        /// </summary>
        /// <returns></returns>
        public double GetGamma()
        {
            double q    = EquityAnalytics.GetYieldCCLin365(_spot, 0, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double fwd  = EquityAnalytics.GetForwardCCLin365(_spot, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double d1   = (Math.Log(fwd / _strike) + _vol * _vol * _tau / 2) / _vol / Math.Sqrt(_tau);
            var    temp = _nd.ProbabilityDensity(d1);

            return(Math.Exp(q * _tau) * temp / _spot / _vol / Math.Sqrt(_tau));
        }
        /// <summary>
        /// Gets the delta.
        /// </summary>
        /// <returns></returns>
        public double GetDelta()
        {
            double q   = EquityAnalytics.GetYieldCCLin365(_spot, 0, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double fwd = EquityAnalytics.GetForwardCCLin365(_spot, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double d1  = (Math.Log(fwd / _strike) + _vol * _vol * _tau / 2) / _vol / Math.Sqrt(_tau);
            double temp;

            if (!_isCall)
            {
                temp = BasicMath.Ndist(d1) - 1;
            }
            else
            {
                temp = BasicMath.Ndist(d1);
            }
            return(Math.Exp(-q * _tau) * temp);
        }
Exemple #5
0
        /// <summary>
        /// Gets the price.
        /// </summary>
        /// <returns></returns>
        public double GetPrice()
        {
            double fwd           = EquityAnalytics.GetForwardCCLin365(_Spot, _tau, _divdays, _divamts, _ratedays, _rateamts);
            double r             = EquityAnalytics.GetRateCCLin365(0, _tau, _ratedays, _rateamts);
            double q             = EquityAnalytics.GetYieldCCLin365(_Spot, 0, _tau, _divdays, _divamts, _ratedays, _rateamts);
            double df            = EquityAnalytics.GetDFCCLin365(0, _tau, _ratedays, _rateamts);
            double flatskewPrice = df * FlatSkewPrice(fwd, r, q);

            double[] res      = OptionAnalytics.OptWithGreeks(true, fwd, _Strike, _vol, _tau);
            double   callvega = res[3];
            double   price;

            if (_isCall)
            {
                price = flatskewPrice - _skew * df * callvega;
            }
            else
            {
                price = flatskewPrice + _skew * df * callvega;
            }
            return(price);
        }
        /// <summary>
        /// Gets the theta.
        /// </summary>
        /// <returns></returns>
        public double GetTheta()
        {
            double q    = EquityAnalytics.GetYieldCCLin365(_spot, 0, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double fwd  = EquityAnalytics.GetForwardCCLin365(_spot, _tau, _divdays, _divamts, _rtdays, _rtamts);
            double d1   = (Math.Log(fwd / _strike) + _vol * _vol * _tau / 2) / _vol / Math.Sqrt(_tau);
            double rate = EquityAnalytics.GetRateCCLin365(0, _tau, _rtdays, _rtamts);
            double d2   = d1 - _vol * Math.Sqrt(_tau);
            double rhs1 = -Math.Exp(-q * _tau) * _spot * _nd.ProbabilityDensity(d1) * _vol / 2 / Math.Sqrt(_tau);
            double rhs3 = 0;

            if (_isCall)
            {
                double rhs2 = -rate *_strike *Math.Exp(-rate *_tau) * _nd.CumulativeDistribution(d2);

                //rhs3 = q * _spot * System.Math.Exp(-q * _tau) * _nd.CumulativeDistribution(d1);
                return((rhs1 + rhs2 + rhs3) / 365.0);
            }
            else
            {
                double rhs2 = rate * _strike * Math.Exp(-rate * _tau) * _nd.CumulativeDistribution(-d2);
                //rhs3 = -q * _spot * System.Math.Exp(-q * _tau) * _nd.CumulativeDistribution(-d1);
                return((rhs1 + rhs2 + rhs3) / 365.0);
            }
        }
Exemple #7
0
 /// <summary>
 /// Gets the AT MFWD.
 /// </summary>
 /// <param name="ratedays">The ratedays.</param>
 /// <param name="rateamts">The rateamts.</param>
 /// <param name="divdays">The divdays.</param>
 /// <param name="divamts">The divamts.</param>
 /// <param name="t">The t.</param>
 /// <returns></returns>
 public double GetATMfwd(int[] ratedays, double[] rateamts, int[] divdays, double[] divamts, double t)
 {
     return(EquityAnalytics.GetForwardCCLin365(_spot, t, divdays, divamts, ratedays, rateamts));
 }