public ScriptChartContext GetWatchContext(DateTime dateFrom, DateTime dateTo)
        {
            ScriptChartContext context = new ScriptChartContext();

            {
                ScriptChartData data_10yr_spot = new ScriptChartData();
                List<RawMarketData> spotRmds = _dataSpot10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_spot.Data = TimeDoublePairUtil.ConvertToCurRate(spotRmds, 1.0F);

                data_10yr_spot.Legend = "10 yr spot data cur";
                context.ChartData.Add(data_10yr_spot.Legend, data_10yr_spot);
            }

            {
                ScriptChartData data_10yr_future = new ScriptChartData();
                List<RawMarketData> rmds = _dataFuture10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_future.Data = TimeDoublePairUtil.ConvertToCurRate(rmds, 100.0F);
                data_10yr_future.Legend = "10 yr future data cur";

                context.ChartData.Add(data_10yr_future.Legend, data_10yr_future);
            }

            context.Description = "10yr future-spot chart.";

            return context;
        }
        public ScriptChartContext GetWatchContext(DateTime dateFrom, DateTime dateTo)
        {
            ScriptChartContext context = new ScriptChartContext();

            {
                ScriptChartData data_10yr_spot = new ScriptChartData();
                List<RawMarketData> spotRmds = _dataSpot10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_spot.Data = TimeDoublePairUtil.ConvertToCur(spotRmds, 1.0F);
                data_10yr_spot.Legend = "10 yr spot data cur";
                context.ChartData.Add(data_10yr_spot.Legend, data_10yr_spot);

                ScriptChartData data_10yr_future_regression = new ScriptChartData();
                List<RawMarketData> rmds = _dataFuture10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_future_regression.Data = TimeDoublePairUtil.ConvertToCur(rmds, 1.0F);
                data_10yr_future_regression.Data =
                    TimeDoublePairUtil.ConvertToRegression(data_10yr_future_regression.Data, data_10yr_spot.Data);
                data_10yr_future_regression.Legend = "10 yr future data cur regression";
                context.ChartData.Add(data_10yr_future_regression.Legend, data_10yr_future_regression);
            }

            {
                ScriptChartData data_10yr_spot = new ScriptChartData();
                List<RawMarketData> rmds = _dataSpot10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_spot.Data = TimeDoublePairUtil.ConvertToAsk(rmds, 1.0F);
                data_10yr_spot.Legend = "10 yr spot data ask";

                context.ChartData.Add(data_10yr_spot.Legend, data_10yr_spot);
            }
            {
                ScriptChartData data_10yr_spot = new ScriptChartData();
                List<RawMarketData> rmds = _dataSpot10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_spot.Data = TimeDoublePairUtil.ConvertToBid(rmds, 1.0F);
                data_10yr_spot.Legend = "10 yr spot data bid";

                context.ChartData.Add(data_10yr_spot.Legend, data_10yr_spot);
            }
            {
                ScriptChartData data_10yr_spot = new ScriptChartData();

                List<RawMarketData> spotRmds = _dataSpot10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_spot.Data = TimeDoublePairUtil.ConvertToMid(spotRmds, 1.0F);
                data_10yr_spot.Legend = "10 yr spot data mid";
                context.ChartData.Add(data_10yr_spot.Legend, data_10yr_spot);

                ScriptChartData data_10yr_future_regression = new ScriptChartData();
                List<RawMarketData> rmds = _dataFuture10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_future_regression.Data = TimeDoublePairUtil.ConvertToMid(rmds, 1.0F);
                data_10yr_future_regression.Data =
                    TimeDoublePairUtil.ConvertToRegression(data_10yr_future_regression.Data, data_10yr_spot.Data);
                data_10yr_future_regression.Legend = "10 yr future data mid regression";
                context.ChartData.Add(data_10yr_future_regression.Legend, data_10yr_future_regression);
            }

            context.Description = "10yr future-spot chart.";

            return context;
        }
        public ScriptChartContext GetWatchContext(DateTime dateFrom, DateTime dateTo)
        {
            ScriptChartContext context = new ScriptChartContext();

            {
                ScriptChartData data_10yr_spot = new ScriptChartData();
                List<RawMarketData> rmds = _dataSpot10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_spot.Data = ConvertToCurPricesWithMultiplier(rmds, 1.0F);
                data_10yr_spot.Data = ConvertToDiffFromStart(data_10yr_spot.Data, _dataSpot10yr.GetFirstCurValue());
                data_10yr_spot.Legend = "10 yr spot data cur";

                context.ChartData.Add(data_10yr_spot.Legend, data_10yr_spot);
            }
            {
                ScriptChartData data_10yr_spot = new ScriptChartData();
                List<RawMarketData> rmds = _dataSpot10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_spot.Data = ConvertToAskPricesWithMultiplier(rmds, 1.0F);
                data_10yr_spot.Data = ConvertToDiffFromStart(data_10yr_spot.Data, _dataSpot10yr.GetFirstCurValue());
                data_10yr_spot.Legend = "10 yr spot data ask";

                context.ChartData.Add(data_10yr_spot.Legend, data_10yr_spot);
            }
            {
                ScriptChartData data_10yr_spot = new ScriptChartData();
                List<RawMarketData> rmds = _dataSpot10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_spot.Data = ConvertToBidPricesWithMultiplier(rmds, 1.0F);
                data_10yr_spot.Data = ConvertToDiffFromStart(data_10yr_spot.Data, _dataSpot10yr.GetFirstCurValue());
                data_10yr_spot.Legend = "10 yr spot data bid";

                context.ChartData.Add(data_10yr_spot.Legend, data_10yr_spot);
            }

            {
                ScriptChartData data_10yr_future = new ScriptChartData();
                List<RawMarketData> rmds = _dataFuture10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_future.Data = ConvertToCurPricesWithMultiplier(rmds, 100.0F);
                data_10yr_future.Data = ConvertToDiffFromStart(
                    data_10yr_future.Data, 100.0F * _dataFuture10yr.GetFirstCurValue());

                data_10yr_future.Legend = "10 yr future data cur";

                context.ChartData.Add(data_10yr_future.Legend, data_10yr_future);
            }
            {
                ScriptChartData data_10yr_future = new ScriptChartData();
                List<RawMarketData> rmds = _dataFuture10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_future.Data = ConvertToAskPricesWithMultiplier(rmds, 100.0F);
                data_10yr_future.Data = ConvertToDiffFromStart(
                    data_10yr_future.Data, 100.0F * _dataFuture10yr.GetFirstCurValue());

                data_10yr_future.Legend = "10 yr future data ask";

                context.ChartData.Add(data_10yr_future.Legend, data_10yr_future);
            }
            {
                ScriptChartData data_10yr_future = new ScriptChartData();
                List<RawMarketData> rmds = _dataFuture10yr.GetRmdData(dateFrom, dateTo);
                data_10yr_future.Data = ConvertToBidPricesWithMultiplier(rmds, 100.0F);
                data_10yr_future.Data = ConvertToDiffFromStart(
                    data_10yr_future.Data, 100.0F * _dataFuture10yr.GetFirstCurValue());

                data_10yr_future.Legend = "10 yr future data bid";

                context.ChartData.Add(data_10yr_future.Legend, data_10yr_future);
            }

            context.Description = "10yr future-spot chart.";

            return context;
        }
        void DisplayChart(ScriptChartContext context)
        {
            chart1.Series.Clear();

            double first_min = double.MaxValue;
            double first_max = double.MinValue;

            double second_min = double.MaxValue;
            double second_max = double.MinValue;

            foreach (KeyValuePair<String, ScriptChartData> pair in context.ChartData)
            {
                String legend = pair.Key;
                ScriptChartData data = pair.Value;

                double min = double.MaxValue;
                double max = double.MinValue;

                chart1.Series.Add(legend);
                AddChartSeriesPoint(legend, data, ref min, ref max);
                chart1.Series[legend].ChartType =
                    System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                chart1.Series[legend].XValueType =
                    System.Windows.Forms.DataVisualization.Charting.ChartValueType.String;

                if (data.UseFirstYAxis)
                {
                    if (first_min > min)
                    {
                        first_min = min;
                    }
                    if (first_max < max)
                    {
                        first_max = max;
                    }
                }
                else
                {
                    chart1.Series[legend].YAxisType = AxisType.Secondary;
                    if (second_min > min)
                    {
                        second_min = min;
                    }
                    if (second_max < max)
                    {
                        second_max = max;
                    }
                }
            }

            chart1.ChartAreas[0].AxisX.LineColor = Color.Gray;
            chart1.ChartAreas[0].AxisX.LineWidth = 2;
            chart1.ChartAreas[0].AxisX.LineDashStyle = ChartDashStyle.Solid;

            chart1.ChartAreas[0].AxisY.LineColor = Color.Gray;
            chart1.ChartAreas[0].AxisY.LineWidth = 2;
            chart1.ChartAreas[0].AxisY.LineDashStyle = ChartDashStyle.Solid;

            chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.LightGray;
            chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;

            chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.LightGray;
            chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;

            chart1.ChartAreas[0].BackColor = Color.Transparent;

            double interval = 1.0 / Math.Pow(10, _displayInfo.Precision);

            chart1.ChartAreas[0].AxisY.Minimum = Math.Round(first_min - interval * 1.0, _displayInfo.Precision);
            chart1.ChartAreas[0].AxisY.Maximum = Math.Round(first_max + interval * 1.0, _displayInfo.Precision);
            chart1.ChartAreas[0].AxisY.Interval = interval;

            if (second_min == double.MaxValue || second_max == double.MinValue)
            {
                //skip
            }
            else
            {
                double interval2 = 1.0 / Math.Pow(10, _displayInfo.Precision2);

                chart1.ChartAreas[0].AxisY2.Minimum = Math.Round(second_min - interval * 1.0, _displayInfo.Precision2);
                chart1.ChartAreas[0].AxisY2.Maximum = Math.Round(second_max + interval * 1.0, _displayInfo.Precision2);
                chart1.ChartAreas[0].AxisY2.Interval = interval;
            }

            chart1.Invalidate();
        }
        void Display(ScriptChartContext context)
        {
            DisplayCurDateTime();

            // display text
            richTextBox2.Text = context.Description;

            DisplayChart(context);
        }