private Frame <int, string> CreateNonNormalizedFrame(TimeSeriesResponse response) { Frame <int, string> TotalFrame = Frame.CreateEmpty <int, string>(); int totalIndex = 0; foreach (var timeseries in response.timeseriesData) { var ric = timeseries.ric; var errorCode = timeseries.statusCode; if (errorCode.ToString().ToLower() == "error") { _logger.LogError("Error: {0} {1}", timeseries.ric, timeseries.errorMessage); continue; } Frame <int, string> f = Frame.CreateEmpty <int, string>(); var symbolColumn = Enumerable.Repeat(ric, timeseries.dataPoints.Count()).ToList <string>(); f.AddColumn("Security", CreateSeriesString(symbolColumn, totalIndex)); for (int i = 0; i < timeseries.fields.Count(); i++) { var field = timeseries.fields[i]; var list = timeseries.dataPoints.Select(x => x[i]).ToList(); //f.AddColumn(field.name, CreateSeriesObject(list, totalIndex)); // Console.WriteLine(field.name); if (field.type.ToLower() == "datetime") { f.AddColumn(field.name, CreateSeries <DateTime>(list, totalIndex)); } else if (field.type.ToLower() == "double") { f.AddColumn(field.name, CreateSeriesDouble(list, totalIndex)); } else if (field.type.ToLower() == "integer" || field.type.ToLower() == "int") { f.AddColumn(field.name, CreateSeries <int>(list, totalIndex)); } else { f.AddColumn(field.name, CreateSeries <string>(list, totalIndex)); } } TotalFrame = TotalFrame.Merge(f); totalIndex = totalIndex + timeseries.dataPoints.Count(); } return(TotalFrame); }
private Frame <int, string> CreateNormalizedFrame(TimeSeriesResponse response) { Frame <int, string> TotalFrame = Frame.CreateEmpty <int, string>(); int totalIndex = 0; foreach (var timeseries in response.timeseriesData) { var ric = timeseries.ric; var errorCode = timeseries.statusCode; if (errorCode.ToString().ToLower() == "error") { _logger.LogError("Error: {0} {1}", timeseries.ric, timeseries.errorMessage); continue; } var fields = timeseries.fields.Select(x => x.name).ToList(); var timeStampIndex = fields.IndexOf("TIMESTAMP"); fields.Remove("TIMESTAMP"); var timestamps = timeseries.dataPoints.Select(x => x[timeStampIndex]).ToList(); timeseries.dataPoints.ForEach(x => x.RemoveAt(timeStampIndex)); var fieldCount = fields.Count(); var columnSize = timeseries.dataPoints.Count(); var symbolColumn = Enumerable.Repeat(ric, fieldCount * columnSize).ToList <string>(); var fieldsColumn = Enumerable.Repeat(fields, columnSize).ToList().SelectMany(i => i).ToList(); var valueColumn = timeseries.dataPoints.SelectMany(i => i).ToList(); var timeStampColumn = timestamps.Select(x => Enumerable.Repeat(x, fieldCount).ToList()).ToList().SelectMany(i => i).ToList(); Frame <int, string> f = Frame.CreateEmpty <int, string>(); f.AddColumn("Date", CreateSeries <DateTime>(timeStampColumn, totalIndex)); f.AddColumn("Field", CreateSeriesString(fieldsColumn, totalIndex)); f.AddColumn("Security", CreateSeriesString(symbolColumn, totalIndex)); f.AddColumn("Value", CreateSeriesDouble(valueColumn, totalIndex)); TotalFrame = TotalFrame.Merge(f); totalIndex = totalIndex + (fieldCount * columnSize); } return(TotalFrame); }
private Frame <int, string> CreateFrame(TimeSeriesResponse response, bool normalize = false) { return(CreateNonNormalizedFrame(response)); }