How to call websocket api and make a data set based on time?
ashish fugat
11
Reputation points
I want to call websocket api from data anlytics or data factory which gives continous data from api.
i want to read that data and based on time after every 5 minutes want to take out open high low and close values from that set.
i can able to do it using my c# webjob code but for robust solution looking solution using analytics service.
// here i will get data continously which i will store into below list
var inputList = new SortedSet<MyObject>(new MyObjectComparer());
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 9 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 11 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 13 });
Thread.Sleep(50000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 14 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 16 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 11 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 13 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 12 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 11 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 15 });
Thread.Sleep(10000);
inputList.Add(new MyObject() { Time = DateTime.Now, Value = 16 });
var resultSet = inputList.GroupBy(i => i.GetStartOfPeriodByMins(1)).Select(gr =>
new
{
StartOfPeriod = gr.Key,
Min = gr.Min(item => item.Value),
Max = gr.Max(item => item.Value),
Open = gr.OrderBy(item => item.Time).First().Value,
Close = gr.OrderBy(item => item.Time).Last().Value
});
var my = resultSet.ToList();
Sign in to answer