Exemplo n.º 1
0
        /// <summary>
        /// Gets the collar PCE.
        /// </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="volSurface">The vol surface.</param>
        /// <param name="spot">The spot.</param>
        /// <param name="callstrike">The callstrike.</param>
        /// <param name="putstrike">The putstrike.</param>
        /// <param name="maturity">The maturity of the collar</param>
        /// <param name="meanrev">The meanrev parameter used in the OU dynamics.</param>
        /// <param name="histvol">The historical vol estimate used in the OU dynamics.</param>
        /// <param name="timeSlice">The time slice.</param>
        /// <returns></returns>
        public static double[,] GetCollarPCE(string payoff,
                                             int[] ratedays,
                                             double[] rateamts,
                                             int[] divdays,
                                             double[] divamts,
                                             List <OrcWingParameters> volSurface,
                                             double spot,
                                             double callstrike,
                                             double putstrike,
                                             double maturity,
                                             double kappa,
                                             double theta,
                                             double sigma,
                                             double[] profiletimes,
                                             double confidence,
                                             double tstepSize,
                                             int simulations,
                                             int seed)

        {
            int nprofile = profiletimes.Length;

            double[,] results = new double[nprofile, 3];
            List <double>         profileList   = new List <double>(profiletimes);
            List <double>         _profiletimes = profileList.FindAll(delegate(double item) { return(item <= maturity); });
            List <RiskStatistics> res           = Euler(payoff,
                                                        ratedays,
                                                        rateamts,
                                                        divdays,
                                                        divamts,
                                                        volSurface,
                                                        spot,
                                                        callstrike,
                                                        putstrike,
                                                        maturity,
                                                        _profiletimes.ToArray(),
                                                        kappa,
                                                        theta,
                                                        sigma,
                                                        confidence,
                                                        tstepSize,
                                                        simulations,
                                                        seed);

            for (int idx = 0; idx < _profiletimes.Count; idx++)
            {
                Statistics.Statistics stats = new Statistics.Statistics();
                double[] sample             = res[idx].Sample();
                double   mean     = res[idx].Mean;
                double   sterrEst = res[idx].ErrorEstimate;
                results[idx, 0] = mean;
                results[idx, 1] = stats.Percentile(ref sample, cPercentile);
                results[idx, 2] = sterrEst;
            }

            return(results);
        }