Beispiel #1
0
        ///<summary>
        /// The main function to calculate the adjusted forward.
        ///</summary>
        ///<param name="futuresPriceArray"> Vector of futures prices.</param>
        ///<param name="volatilityRange"> Vector of futures</param>
        ///<param name="correlationRange"> Correlation between forwards. Can be a
        /// scalar input or a correlation matrix.</param>
        ///<param name="shiftArray"> The shift parameters from the BGM
        /// calibration.</param>
        ///<param name="coverageArray"> The vector of time intervals between model
        /// time nodes.</param>
        ///<param name="timeNodesArray"> The model time nodes</param>
        ///<returns> Output, a 2-D array of ouput data. The first column is the
        /// vector of adjusted cash forwards. The second column is the error
        /// from the optimisation (the implied futures rate minus the market
        /// rate). The third column is the number of iterations taken by the
        /// optimisation routine to converge on each adjusted rate. In the first
        /// entry in the fourth and fifth column is the time taken to work
        /// through the whole set of time nodes, and the program version.</returns>
        public object[,] CalculateCashForward(Excel.Range futuresPriceArray,
                                              Excel.Range volatilityRange,
                                              Excel.Range correlationRange,
                                              Excel.Range shiftArray,
                                              Excel.Range coverageArray,
                                              Excel.Range timeNodesArray)
        {
            var futuresPrice = DataRangeHelper.StripDoubleRange(futuresPriceArray);
            var shift        = DataRangeHelper.StripDoubleRange(shiftArray);
            var coverage     = DataRangeHelper.StripDoubleRange(coverageArray);
            var timeNodes    = DataRangeHelper.StripDoubleRange(timeNodesArray);
            var volatility   = DataRangeHelper.ToMatrix <double>(volatilityRange);
            var correlation  = DataRangeHelper.ToMatrix <double>(correlationRange);
            var result       = CashForward.CalculateCashForward(futuresPrice.ToArray(), volatility,
                                                                correlation, shift.ToArray(), coverage.ToArray(), timeNodes.ToArray());

            return(DataRangeHelper.ToRange(result));
        }