示例#1
0
        /// <summary>
        /// Update the formatting in the column grid, the metatable and any displayed data grid
        /// </summary>
        /// <param name="qc"></param>

        void UpdateColumnFormatting(QueryColumn qc)
        {
            SetCustomFormattingGridImage(ColGridDataTable.Rows[CurrentRow]); // update image in column grid
            ColGrid.RefreshDataSource();                                     // redraw column grid

            UpdateMetaColumnFormatting(qc);                                  // update formatting info in metacolumn

            if (DataFormatterOpen && Qm != null)                             // update query and grid headers
            {
                SetupDataGridFormatting();
                RowGrid.DataSource = Qm.DataTable;                 // restore grid datasource to proper data table
            }
            return;
        }
示例#2
0
        /// <summary>
        /// Get a point from the implied vol surface
        /// </summary>
        /// <param name="t">date in double</param>
        /// <param name="k">strike</param>
        /// <returns></returns>
        public double GetValue(double t, double k)
        {
            //check if the point is out of range
            var axisX1InDouble = RowGrid.Select(item => _dayCount.CalcDayCountFraction(ValuationDate, item)).ToList();

            if (t < axisX1InDouble.Min() || t > axisX1InDouble.Max() || k < ColGrid.Min() || k > ColGrid.Max())
            {
                throw new PricingLibraryException(String.Format("Date - strike pair ({0},{1}) is out of range. Extrapolation is not implemented yet", t, k));
            }

            //find the two indices which on the two sides of the input date. If cannot find in the for loop, then i = 0 automatically.
            int i = 0;

            for (int j = 0; j < axisX1InDouble.Count - 1; j++)
            {
                if ((axisX1InDouble[j] < t) && (t <= axisX1InDouble[j + 1]))
                {
                    i = j;
                }
            }

            // get the left and right value of the sabr interpolated vol with the same strike s
            var leftValue = SABRVolFineTune(
                OptimizerResults[i].BestAlpha,
                OptimizerResults[i].BestBeta,
                OptimizerResults[i].BestRho,
                OptimizerResults[i].BestNu,
                _spotPrice,
                k,
                OptimizerResults[i].Maturity,
                _useFineTune);
            var rightValue = SABRVolFineTune(
                OptimizerResults[i + 1].BestAlpha,
                OptimizerResults[i + 1].BestBeta,
                OptimizerResults[i + 1].BestRho,
                OptimizerResults[i + 1].BestNu,
                _spotPrice,
                k,
                OptimizerResults[i + 1].Maturity,
                _useFineTune);

            var w = Weight((OptimizerResults[i + 1].Maturity - t) / (OptimizerResults[i + 1].Maturity - OptimizerResults[i].Maturity));

            return(w * leftValue + (1 - w) * rightValue);
        }
示例#3
0
 public override double MinY()
 {
     return(ColGrid.Min());
 }
示例#4
0
 public override double MaxY()
 {
     return(ColGrid.Max());
 }