Пример #1
0
        /// <summary>
        /// Gets the price.
        /// </summary>
        /// <returns></returns>
        public double GetPrice()
        {
            int numresets = _resetDays.Length;
            int readings  = _resetAmts.Count(item => (item > 0));

            if (readings == numresets)
            {
                double av = _resetAmts.Average();
                double df = EquityAnalytics.GetDFCCLin365(0, _tau, _rtdays, _rtamts);
                return((av - _strike) * df);
            }
            double newstrike = TransformStrike(numresets, readings);
            int    nleft     = numresets - readings;

            int[]    reset_days = new int[nleft];
            double[] vols       = new double[nleft];
            for (int idx = 0; idx < nleft; idx++)
            {
                reset_days[idx] = _resetDays[idx + readings];
                vols[idx]       = _vols[idx + readings];
            }
            double newprice = GetPrice(newstrike, numresets - readings, reset_days, vols);

            return(newprice * (numresets - readings) / numresets);
        }
Пример #2
0
        /// <summary>
        /// Gets the price.
        /// </summary>
        /// <param name="strike">The strike.</param>
        /// <param name="numResets">The num_resets.</param>
        /// <param name="resetDays"></param>
        /// <param name="vols">The vols.</param>
        /// <returns></returns>
        public double GetPrice(double strike, int numResets, int[] resetDays, double[] vols)
        {
            double bond    = 0.0;
            int    numVols = _vols.Length;

            double[] covxxi;
            double[] varlogs;
            double[] forwards = new double[numResets];
            double   mu       = CalcMu(ref forwards, resetDays, vols);
            double   sigma    = CalcSigma(resetDays, vols);

            varlogs = CalcVarLogs(resetDays, vols);
            covxxi  = CalcCovXXI(varlogs, vols.Length);
            if (strike <= 0)
            {
                bond   = System.Math.Abs(strike);
                strike = cEpsilon;
            }
            double z0 = (mu - System.Math.Log(strike)) / sigma;
            double i1 = 0.0;

            for (int idx = 0; idx < numResets; idx++)
            {
                double x1 = z0 + (covxxi[idx] / sigma);
                double n1 = _nd.CumulativeDistribution(x1);
                i1 += n1 * forwards[idx] / (double)numResets;
            }
            double i2   = strike * _nd.CumulativeDistribution(z0);
            double prem = i1 - i2;
            double df   = EquityAnalytics.GetDFCCLin365(0, _tau, _rtdays, _rtamts);

            return((prem + bond) * df);
        }
Пример #3
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);
        }