Beispiel #1
0
        private List <Kline> ConvertJsonsToKlines(List <JObject> jsons, string symbol, string interval)
        {
            try
            {
                var klines = new List <Kline>();
                //var klineInterval = EnumCollection.ConvertIntervalStringToEnum(interval);

                foreach (var j in jsons)
                {
                    var kline = new Kline();
                    kline.Symbol    = symbol;
                    kline.Interval  = interval;
                    kline.OpenTime  = long.Parse(j["OpenTime"].ToString());
                    kline.Open      = decimal.Parse(j["Open"].ToString());
                    kline.High      = decimal.Parse(j["High"].ToString());
                    kline.Low       = decimal.Parse(j["Low"].ToString());
                    kline.Close     = decimal.Parse(j["Close"].ToString());
                    kline.Volume    = decimal.Parse(j["Volume"].ToString());
                    kline.CloseTime = long.Parse(j["CloseTime"].ToString());

                    klines.Add(kline);
                }
                return(klines);
            }
            catch (Exception e)
            {
                _logger.Error("Failed to Parse JObject to CandleSticks.\n" + e.ToString());
                return(null);
            }
        }
Beispiel #2
0
        public List <Kline> ParseKlinesFromCsvToList(List <string> list)
        {
            try
            {
                var klineList = new List <Kline>();
                foreach (var line in list)
                {
                    if (!line.StartsWith("Symbol"))
                    {
                        var split = line.Split(',');
                        var kline = new Kline();

                        kline.Symbol    = split[0];
                        kline.Interval  = split[1];
                        kline.OpenTime  = long.Parse(split[2]);
                        kline.CloseTime = long.Parse(split[3]);
                        kline.Open      = decimal.Parse(split[4]);
                        kline.Close     = decimal.Parse(split[5]);
                        kline.High      = decimal.Parse(split[6]);
                        kline.Low       = decimal.Parse(split[7]);
                        kline.Volume    = decimal.Parse(split[8]);
                        klineList.Add(kline);
                    }
                }

                return(klineList);
            }
            catch (Exception e)
            {
                _logger.Error("Failed to parse klines from text to kline list.\n" + e.ToString());
                return(null);
            }
        }