Exemple #1
0
        public void Test_AxisLine_FarAwayExpandXY()
        {
            Random rand = new Random(0);

            var plt  = new ScottPlot.Plot();
            var data = DataGen.RandomWalk(rand, 100);

            plt.PlotSignal(data, xOffset: 100, yOffset: 100, label: "scatter");
            plt.PlotVLine(-100, label: "vertical");
            plt.PlotHLine(-100, label: "horizontal");
            plt.Legend();

            TestTools.SaveFig(plt);
        }
Exemple #2
0
        private ScottPlot.Plot GetDemoPlot()
        {
            Random rand = new Random(0);
            var    plt  = new ScottPlot.Plot();

            plt.PlotScatter(ScottPlot.DataGen.Random(rand, 100, 20), ScottPlot.DataGen.Random(rand, 100, 5, 3), label: "scatter1");
            plt.PlotSignal(ScottPlot.DataGen.RandomWalk(rand, 100), label: "signal1");
            plt.PlotScatter(ScottPlot.DataGen.Random(rand, 100), ScottPlot.DataGen.Random(rand, 100), label: "scatter2");
            plt.PlotSignal(ScottPlot.DataGen.RandomWalk(rand, 100), label: "signal2");
            plt.PlotVLine(43, lineWidth: 4, label: "vline");
            plt.PlotHLine(1.23, lineWidth: 4, label: "hline");
            plt.PlotText("ScottPlot", 50, 0.25, rotation: -45, fontSize: 36, label: "text");
            plt.Legend();
            return(plt);
        }
Exemple #3
0
        public static string chart(string pair)
        {
            List <string> pena = new List <string>();

            System.Net.WebClient wc1 = new System.Net.WebClient();
            int    sum_chart         = 150;
            double last_price        = 0;
            String link_Response     = wc1.DownloadString("https://www.binance.com/api/v1/klines?symbol=" + pair + "&interval=15m&limit=" + sum_chart);

            MatchCollection matchList = System.Text.RegularExpressions.Regex.Matches(link_Response, @"(\d+.\d+)|\d+\d+|\d");

            pena = matchList.Cast <Match>().Select(match => match.Value).ToList();
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            int count      = 0;
            int count_draw = 0;

            //Оишбка в апи hbc в конце несколкьо нулей 0 0 0 0 0
            //введен костыль-переменная
            ScottPlot.OHLC[] ohlcs = new ScottPlot.OHLC[sum_chart];
            var plt = new ScottPlot.Plot(800, 400);

            for (int i = 0; i < sum_chart; i++)
            {
                double Open     = Convert.ToDouble(pena[count_draw + 1]);
                double High     = Convert.ToDouble(pena[count_draw + 2]);
                double Low      = Convert.ToDouble(pena[count_draw + 3]);
                double Close    = Convert.ToDouble(pena[count_draw + 4]);
                double Opentime = ((Convert.ToDouble(pena[count_draw])) / 1000) + (3600 * 3);

                ohlcs[count] = new ScottPlot.OHLC(Open, High, Low, Close, ConvertFromUnixTimestamp(Opentime), 1);
                count_draw   = count_draw + 12;
                count++;
                last_price = Close;
            }

            plt.Title("15 Minute Chart");
            plt.YLabel("Stock Price (" + pair + ")");
            plt.Ticks(dateTimeX: true, dateTimeFormatStringX: "HH:mm:ss", numericFormatStringY: "n");
            plt.PlotCandlestick(ohlcs);
            plt.Style(tick: Color.White, label: Color.White, title: Color.White, dataBg: Color.FromArgb(255, 36, 43, 60), grid: Color.FromArgb(255, 36, 43, 60), figBg: Color.FromArgb(255, 36, 43, 60));
            DateTime date1 = new DateTime();

            date1 = DateTime.Now;

            string name = "PlotTypes" + pair + "№" + date1.Ticks + ".png";

            string name_file  = name;
            string label_name = Convert.ToString(last_price);

            plt.PlotHLine(y: last_price, color: Color.Green, lineWidth: 0.5, label: label_name);
            plt.Legend(backColor: Color.FromArgb(255, 36, 43, 60), location: legendLocation.upperCenter);



            plt.SaveFig(name_file);



            return(name_file);
        }