Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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));
        }
Esempio n. 3
0
        /// <summary>
        /// Calcs the mu.
        /// </summary>
        /// <param name="resetDays"></param>
        /// <param name="vols">The vols.</param>
        /// <param name="forwards">The forwards.</param>
        /// <returns></returns>
        private double CalcMu(ref double[] forwards, int[] resetDays, double[] vols)
        {
            double musum     = 0;
            int    numresets = resetDays.Length;

            for (int idx = 0; idx < numresets; idx++)
            {
                double dt0 = Convert.ToDouble(resetDays[idx]) / daybasis;
                double r0  = EquityAnalytics.GetRateCCLin365(0, dt0, _rtdays, _rtamts);
                double q0  = EquityAnalytics.GetYieldCCLin365(_spot, 0, dt0, _divdays, _divamts, _rtdays, _rtamts);

                musum        += System.Math.Log(_spot) + (r0 - q0) * dt0 - vols[idx] * vols[idx] * dt0 / 2;
                forwards[idx] = _spot * System.Math.Exp((r0 - q0) * dt0);
            }
            return(musum / numresets);
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 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);
        }
Esempio n. 6
0
        /// <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);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Gets the yield.
 /// </summary>
 /// <param name="yearFraction">The year fraction.</param>
 /// <returns></returns>
 private double GetYield(double yearFraction)
 {
     return(EquityAnalytics.GetYieldCCLin365(_spot, 0, yearFraction, _divDays, _divAmts, _rateDays, _rateAmts));
 }