예제 #1
0
        public Queue_Report GetReport()
        {
            Queue_Report r = new Queue_Report();

            using (ExcelPackage pack_xml = new ExcelPackage(new FileInfo(string_doc)))
            {
                var text    = pack_xml.Workbook.Worksheets.First();
                var columns = text.Dimension.End.Column;
                var rows    = text.Dimension.End.Row;

                for (int i = 2; i <= rows; i++)
                {
                    var row = text.Cells[i, 1, i, columns].Select(c => c.Value == null ? string.Empty : c.Value.ToString()).ToArray();

                    string data_t_row = row[2] + " " + row[3];

                    DateTime data_time = DateTime.ParseExact(data_t_row, "yyyyMMdd HHmmss", null);

                    Candle candle = new Candle()
                    {
                        High      = int.Parse(row[5]),
                        Low       = int.Parse(row[6]),
                        Open      = int.Parse(row[4]),
                        Close     = int.Parse(row[7]),
                        Time      = data_time,
                        TimeStamp = ((DateTimeOffset)data_time).ToUnixTimeMilliseconds(),
                    };

                    r.Push(candle);
                }
            }

            return(r);
        }
예제 #2
0
        public Queue_Report GetReport()
        {
            Queue_Report r = new Queue_Report();

            dynamic json = JsonConvert.DeserializeObject(File.ReadAllText(string_doc));

            var high = ((JArray)json.h);
            var low  = ((JArray)json.l);

            var open       = ((JArray)json.o);
            var close      = ((JArray)json.c);
            var timestamps = ((JArray)json.t);

            for (int i = 0; i < timestamps.Count; i++)
            {
                Candle candle = new Candle()
                {
                    High      = (decimal)high[i],
                    Low       = (decimal)low[i],
                    Open      = (decimal)open[i],
                    Close     = (decimal)close[i],
                    Time      = DateTimeOffset.FromUnixTimeSeconds((long)timestamps[i]).UtcDateTime,
                    TimeStamp = (long)timestamps[i],
                };

                r.Push(candle);
            }

            return(r);
        }
예제 #3
0
        public void RunMonitor()
        {
            stream_data = source_data.GetReport();
            s           = c.Calculation(stream_data);

            thread = new Thread(new ThreadStart(UpdateMonitor));
            thread.Start();
        }
예제 #4
0
        public IId_Serie Calculation(Queue_Report report)
        {
            IId_Serie return_serie  = new Id_Serie();
            var       candles_serie = report.candles.ToList();

            for (int i = 0; i < candles_serie.Count; i++)
            {
                if (i < candles_serie.Count - 5)
                {
                    List <double?> candels_high = new List <double?>(5);
                    List <double?> candels_low  = new List <double?>(5);
                    for (int j = i; j < i + 5; j++)
                    {
                        candels_high.Add((double?)candles_serie[j].High);
                        candels_low.Add((double?)candles_serie[j].Low);
                    }
                    double max = candels_high.Max(), min = candels_low.Min();
                    return_serie.Push(0); return_serie.Push(0);
                    if (min == candels_low[2])
                    {
                        return_serie.Push(min);
                    }
                    else if (max == candels_high[2])
                    {
                        return_serie.Push(max);
                    }
                    else
                    {
                        return_serie.Push(0);
                    }
                    return_serie.Push(0); return_serie.Push(0);
                }
            }

            return(return_serie);
        }