public void fillChart()
        {
#if DEBUG
            try
#endif
            {
                Series serPrice = new Series();

                serPrice.ChartType = SeriesChartType.Line;

                serPrice.Name = "Option PL";

                //gridViewSpreadGrid.RowCount = liveADMDataList.liveADMLegList.Count;

                int legCount = 0;

                int futureIdx = -1;

                while (legCount < gridViewSpreadGrid.RowCount)
                {
                    String contractType = gridViewSpreadGrid.Rows[legCount]
                                          .Cells[(int)OPTION_PL_COLUMNS.CONTRACT_TYPE].Value.ToString();

                    if (contractType.CompareTo(optionArrayTypes.optionSpreadContractTypesArray.GetValue(
                                                   (int)OPTION_SPREAD_CONTRACT_TYPE.FUTURE)) == 0)
                    {
                        futureIdx = legCount;
                        break;
                    }

                    legCount++;
                }

                int countOftest = 1000;

                double futureAvgPrice;

                if (futureIdx >= 0)
                {
                    futureAvgPrice = ConversionAndFormatting.convertToTickMovesDouble(
                        gridViewSpreadGrid.Rows[futureIdx]
                        .Cells[(int)OPTION_PL_COLUMNS.AVG_PRICE].Value.ToString(),
                        instrument.tickSize, instrument.tickDisplay);
                }
                else
                {
                    futureAvgPrice = futurePrice;
                }


                double[] futurePriceArray = new double[countOftest * 2 + 1];

                //double futureAvgPrice = (double)gridViewSpreadGrid.Rows[futureIdx]
                //                    .Cells[(int)OPTION_PL_COLUMNS.AVG_PRICE].Value;

                //double futureAvgPrice = (double)gridViewSpreadGrid.Rows[futureIdx]
                //                    .Cells[(int)OPTION_PL_COLUMNS.AVG_PRICE].Value;
                //double futureAvgPrice = ConversionAndFormatting.convertToTickMovesDouble(
                //                gridViewSpreadGrid.Rows[futureIdx]
                //                    .Cells[(int)OPTION_PL_COLUMNS.AVG_PRICE].Value.ToString(),
                //                instrument.tickSize, instrument.tickDisplay);

                //futureAvgPrice /= instrument.admFuturePriceFactor;

                double startOfTest =
                    futureAvgPrice
                    - countOftest *
                    instrument.tickSize;
                //optionBuilderSpreadStructure[
                //    currentDateContractListMainIdx[aDMDataListSpreadCount][(int)OPTION_SPREAD_ROLL_INDEXES.OPTION_SPREAD_IDX]
                //    ].instrument.tickSize;

                if (startOfTest < 0)
                {
                    startOfTest = 0;
                }

                for (int count = 0; count < futurePriceArray.Length; count++)
                {
                    futurePriceArray[count] = startOfTest +
                                              count *
                                              instrument.tickSize;
                    //optionBuilderSpreadStructure[
                    //currentDateContractListMainIdx[aDMDataListSpreadCount][(int)OPTION_SPREAD_ROLL_INDEXES.OPTION_SPREAD_IDX]
                    //].instrument.tickSize;
                }


                double[,] legPls = new double[gridViewSpreadGrid.RowCount, futurePriceArray.Length];

                double[] spreadPl = new double[futurePriceArray.Length];

                double riskFreeRate = Convert.ToDouble(riskFreeTextBox.Text) / 100;

                for (int futurePointCount = 0; futurePointCount < futurePriceArray.Length; futurePointCount++)
                {
                    double plTotal = 0;

                    legCount = 0;

                    //for (int legCounter = 0; legCounter < gridViewSpreadGrid.RowCount   ;
                    //    legCounter++)
                    while (legCount < gridViewSpreadGrid.RowCount)
                    {
                        int  cellCount       = 0;
                        bool continueThisLeg = true;
                        while (cellCount < gridViewSpreadGrid.Rows[legCount].Cells.Count)
                        {
                            if (gridViewSpreadGrid.Rows[legCount].Cells[cellCount].Value == null)
                            {
                                continueThisLeg = false;
                                break;
                            }

                            cellCount++;
                        }

                        if (continueThisLeg)
                        {
                            String contractType = gridViewSpreadGrid.Rows[legCount]
                                                  .Cells[(int)OPTION_PL_COLUMNS.CONTRACT_TYPE].Value.ToString();

                            //double strike = Convert.ToDouble(gridViewSpreadGrid.Rows[legCount]
                            //                        .Cells[(int)OPTION_PL_COLUMNS.STRIKE].Value);

                            double strike =
                                ConversionAndFormatting.convertToTickMovesDouble(
                                    gridViewSpreadGrid.Rows[legCount].Cells[(int)OPTION_PL_COLUMNS.STRIKE].Value.ToString(),
                                    instrument.optionStrikeIncrement,
                                    instrument.optionStrikeDisplay);

                            double daysToExp = Convert.ToDouble(gridViewSpreadGrid.Rows[legCount]
                                                                .Cells[(int)OPTION_PL_COLUMNS.DAYS_TO_EXP].Value);
                            daysToExp /= 365;

                            double implVol = Convert.ToDouble(gridViewSpreadGrid.Rows[legCount]
                                                              .Cells[(int)OPTION_PL_COLUMNS.IMPLIED_VOL].Value);
                            //implVol = 15;
                            implVol /= 100;

                            double numOfContracts = Convert.ToDouble(gridViewSpreadGrid.Rows[legCount]
                                                                     .Cells[(int)OPTION_PL_COLUMNS.NET].Value);

                            double avgPrice = 0;  // Convert.ToDouble(gridViewSpreadGrid.Rows[legCount]
                            //   .Cells[(int)OPTION_PL_COLUMNS.AVG_PRICE].Value);

                            if (contractType.CompareTo(optionArrayTypes.optionSpreadContractTypesArray.GetValue(
                                                           (int)OPTION_SPREAD_CONTRACT_TYPE.FUTURE)) == 0)
                            {
                                avgPrice = ConversionAndFormatting.convertToTickMovesDouble(
                                    gridViewSpreadGrid.Rows[legCount]
                                    .Cells[(int)OPTION_PL_COLUMNS.AVG_PRICE].Value.ToString(),
                                    instrument.tickSize, instrument.tickDisplay);
                            }
                            else
                            {
                                if (instrument.secondaryOptionTickSizeRule > 0)
                                {
                                    avgPrice = ConversionAndFormatting.convertToTickMovesDouble(
                                        gridViewSpreadGrid.Rows[legCount]
                                        .Cells[(int)OPTION_PL_COLUMNS.AVG_PRICE].Value.ToString(),
                                        instrument.secondaryOptionTickSize, instrument.optionTickDisplay);
                                }
                                else
                                {
                                    avgPrice = ConversionAndFormatting.convertToTickMovesDouble(
                                        gridViewSpreadGrid.Rows[legCount]
                                        .Cells[(int)OPTION_PL_COLUMNS.AVG_PRICE].Value.ToString(),
                                        instrument.optionTickSize, instrument.optionTickDisplay);
                                }
                            }

                            char   typeSymbol;
                            bool   run = true;
                            double price;
                            double tickSize;
                            double tickValue;

                            if (contractType.CompareTo(optionArrayTypes.optionSpreadContractTypesArray.GetValue(
                                                           (int)OPTION_SPREAD_CONTRACT_TYPE.CALL)) == 0)
                            {
                                typeSymbol = 'C';

                                price = OptionCalcs.blackScholes(typeSymbol,
                                                                 futurePriceArray[futurePointCount],
                                                                 strike,
                                                                 daysToExp, riskFreeRate,
                                                                 implVol);

                                tickSize  = instrument.optionTickSize;
                                tickValue = instrument.optionTickValue;

                                //run = false;
                            }
                            else if (contractType.CompareTo(optionArrayTypes.optionSpreadContractTypesArray.GetValue(
                                                                (int)OPTION_SPREAD_CONTRACT_TYPE.PUT)) == 0)
                            {
                                typeSymbol = 'P';

                                price = OptionCalcs.blackScholes(typeSymbol,
                                                                 futurePriceArray[futurePointCount],
                                                                 strike,
                                                                 daysToExp, riskFreeRate,
                                                                 implVol);

                                tickSize  = instrument.optionTickSize;
                                tickValue = instrument.optionTickValue;

                                //run = false;
                            }
                            else
                            {
                                typeSymbol = 'F';

                                price = futurePriceArray[futurePointCount];

                                tickSize  = instrument.tickSize;
                                tickValue = instrument.tickValue;

                                //run = true;
                            }

                            if (run)
                            {
                                double pl =
                                    numOfContracts *
                                    (price - avgPrice)
                                    / tickSize
                                    * tickValue;

                                plTotal += pl;

                                legPls[legCount, futurePointCount] = pl;
                            }
                        }
                        legCount++;
                    }

                    spreadPl[futurePointCount] = plTotal;

                    DataPoint dp = new DataPoint();

                    dp.SetValueXY(
                        ConversionAndFormatting.convertToTickMovesString(
                            futurePriceArray[futurePointCount],
                            instrument.tickSize, instrument.tickDisplay),
                        //Math.Round(futurePriceArray[futurePointCount], 2),
                        plTotal);
                    //dp.SetValueY(plTotal);

                    serPrice.Points.Add(dp);
                }

                chart1.Series.Clear();
                chart1.ResetAutoValues();

                chart1.Series.Add(serPrice);
            }
#if DEBUG
            catch (Exception ex)
            {
                TSErrorCatch.errorCatchOut(Convert.ToString(this), ex);
            }
#endif
        }