/// <summary>
        /// Draw the X,Y axis of the Stock snapshot,  To build up the main stock chart
        /// </summary>
        /// <param name="canvas"></param>
        public void DrawStockMajorToCanvas(ref Canvas canvas)
        {
            double xmin  = marginX;
            double xmax  = width - marginX;
            double ymin  = marginY;
            double ymax  = height - marginY;
            double stepX = (xmax - xmin) / (x_count - 1);
            double stepY = (ymax - ymin) / (y_count - 1);

            BuilderTools.Axis(ref canvas, xmin, xmax, ymax, ymax, x_count, 0, datesAxisKeypoint, 1, Brushes.Black);   // build x
            BuilderTools.Axis(ref canvas, xmin, xmin, ymin, ymax, y_count, 1, pricesAxisKeypoint, 1, Brushes.Black);  //build y1 for price
            BuilderTools.Axis(ref canvas, xmax, xmax, ymin, ymax, y_count, 1, volumesAxisKeypoint, 1, Brushes.Black); // build y2 for volume
            var points = stockData.Charts[Constant.ChartMapper[type]];

            if (menuSetting.ChartSettings["CHARTTYPE"])
            {
                var stockPath = BuilderTools.LineChart(xmin, ymin, ymax, stepX, stepY, points.Select(p => p.ClosePrice).ToList(), 0, GeneralTools.StringParser(pricesAxisKeypoint[0]), GeneralTools.StringParser(pricesAxisKeypoint.Last()), 1, Brushes.Blue, false);
                canvas.Children.Add(stockPath);
            }
            else
            {
                var stockPath = BuilderTools.CandleChart(xmin, ymin, ymax, stepX, stepY, points.Select(p => p.OpenPrice).ToList(), points.Select(p => p.ClosePrice).ToList(), points.Select(p => p.HighPrice).ToList(), points.Select(p => p.LowPrice).ToList(), 0, GeneralTools.StringParser(pricesAxisKeypoint[0]), GeneralTools.StringParser(pricesAxisKeypoint.Last()), 1, Brushes.Blue, false);
                foreach (var p in stockPath)
                {
                    canvas.Children.Add(p);
                }
            }
            if (menuSetting.ChartSettings["SMA10"])
            {
                var sma_10 = BuilderTools.LineChart(xmin, ymin, ymax, stepX, stepY, points.Select(p => p.SMA_10).ToList(), 0, GeneralTools.StringParser(pricesAxisKeypoint[0]), GeneralTools.StringParser(pricesAxisKeypoint.Last()), 2, Brushes.Green, true);
                canvas.Children.Add(sma_10);
            }
            if (menuSetting.ChartSettings["SMA50"])
            {
                var sma_50 = BuilderTools.LineChart(xmin, ymin, ymax, stepX, stepY, points.Select(p => p.SMA_50).ToList(), 0, GeneralTools.StringParser(pricesAxisKeypoint[0]), GeneralTools.StringParser(pricesAxisKeypoint.Last()), 2, Brushes.DarkSeaGreen, true);
                canvas.Children.Add(sma_50);
            }
            if (menuSetting.ChartSettings["SMA200"])
            {
                var sma_200 = BuilderTools.LineChart(xmin, ymin, ymax, stepX, stepY, points.Select(p => p.SMA_200).ToList(), 0, GeneralTools.StringParser(pricesAxisKeypoint[0]), GeneralTools.StringParser(pricesAxisKeypoint.Last()), 2, Brushes.Blue, true);
                canvas.Children.Add(sma_200);
            }

            //start to draw stock
            if (menuSetting.ChartSettings["VOLUME"])
            {
                var volumePath = GetVolumeChartPath(xmin, ymin, ymax, stepX, stepY, VolumeStringToVolume(volumesAxisKeypoint.Last()));
                canvas.Children.Add(volumePath);
            }
            if (menuSetting.ChartSettings["TREND"] && menuSetting.ChartType == Constant.DAILYCHART)
            {
                var TrendPath = GetTrendLineChartPath(xmin, ymin, ymax, stepX, stepY, GeneralTools.StringParser(pricesAxisKeypoint[0]), GeneralTools.StringParser(pricesAxisKeypoint.Last()), 2, Brushes.LightBlue, false);
                canvas.Children.Add(TrendPath[0]);
                canvas.Children.Add(TrendPath[1]);
            }
            canvas.MouseDown += new MouseButtonEventHandler(AddPointInfo);
            canvas.MouseUp   += new MouseButtonEventHandler(RemovePointInfo);
        }
        public void DrawRSIToCanvas(ref Canvas canvas, int y_count)
        {
            double ymin  = 5;
            double ymax  = canvas.Height - 5;
            double xmin  = marginX;
            double xmax  = canvas.Width - marginX;
            double stepX = (xmax - xmin) / (x_count - 1);
            double stepY = (ymax - ymin) / (y_count - 1);

            BuilderTools.Axis(ref canvas, xmin, xmax, ymax - 10, ymax - 10, x_count, 0, datesAxisKeypoint, 1, Brushes.Black);
            List <string> RSI = new List <string>()
            {
                "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"
            };

            BuilderTools.Axis(ref canvas, xmin, xmin, ymin, ymax, y_count, 1, RSI, 1, Brushes.Black);
            var points  = stockData.Charts[Constant.ChartMapper[type]];
            var RSIPath = BuilderTools.LineChart(xmin, ymin, ymax, stepX, stepY, points.Select(p => p.RSI).ToList(), 0, 0, 100, 2, Brushes.Blue, false);

            canvas.Children.Add(RSIPath);
            canvas.MouseDown += new MouseButtonEventHandler(AddPointInfo);
            canvas.MouseUp   += new MouseButtonEventHandler(RemovePointInfo);
        }
        /// <summary>
        /// currently 0 -> MACD; 1->RSI
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="y_count"></param>
        /// <param name="type"></param>
        public void DrawMACDToCanvas(ref Canvas canvas, int y_count)
        {
            double ymid  = canvas.Height / 2;
            double xmin  = marginX;
            double xmax  = canvas.Width - marginX;
            double stepX = (xmax - xmin) / (x_count - 1);
            double stepY = canvas.Height / (y_count - 1);

            BuilderTools.Axis(ref canvas, xmin, xmax, ymid, ymid, x_count, 0, datesAxisKeypoint, 1, Brushes.Black);
            BuilderTools.Axis(ref canvas, xmin, xmin, 0, 2 * ymid, y_count, 1, MACDAxisKeypoint, 1, Brushes.Black);

            var lowVal   = GeneralTools.StringParser(MACDAxisKeypoint.First());
            var highVal  = GeneralTools.StringParser(MACDAxisKeypoint.Last());
            var MACDPath = GetMACDChartPath(xmin, ymid, stepX, stepY, lowVal, highVal);

            foreach (var path in MACDPath)
            {
                canvas.Children.Add(path);
            }

            canvas.MouseDown += new MouseButtonEventHandler(AddPointInfo);
            canvas.MouseUp   += new MouseButtonEventHandler(RemovePointInfo);
        }