Hardik Dhankecha
New member
Hi,
I am connecting to Polygon.io using websocket for fetch live market data. We are getting nearly 70,000 records on every minute, and after that I am storing those records according to particular that symbols. Like we get AAPL data then we will store that data into AAPL file, and so on. Same process is for 10,000 symbols, means we need to handle 10,000 files at a time. So when I apply store data into file logic on response then socket response become slower and we are getting message like connection close.
I am using c# for development.
And here I have write my few lines of code for explanation.
So how to make this process very fast ? I am expecting that we need to make fast process same as we are receiving response in websocket.
I am connecting to Polygon.io using websocket for fetch live market data. We are getting nearly 70,000 records on every minute, and after that I am storing those records according to particular that symbols. Like we get AAPL data then we will store that data into AAPL file, and so on. Same process is for 10,000 symbols, means we need to handle 10,000 files at a time. So when I apply store data into file logic on response then socket response become slower and we are getting message like connection close.
I am using c# for development.
And here I have write my few lines of code for explanation.
C#:
public static void WriteRecord(string data)
{
List<LiveAMData> ld = JsonConvert.DeserializeObject<List<LiveAMData>>(data);
foreach (var item in ld)
{
var fileName = @"D:\MINUTESANDSECONDS\AAPL_QuoteTicks.txt";
fileLines = System.IO.File.ReadAllLines(fileName).AsParallel().Skip(1).ToList();
var timeInTicks = Convert.ToInt64(item.t) * TimeSpan.TicksPerMillisecond;
var result = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddTicks(timeInTicks);
DateTime newDT = TimeZoneInfo.ConvertTimeFromUtc(result, targetZone);
fileLines.Add(item.sym +"," +newDT.ToString("dd/MM/yyyy")+","+item.ax +","+item.bx+","+item.ap+","+item.bp+","+item.@as+","+item.bs);
System.IO.File.WriteAllLines(fileName, fileLines);
}
}
So how to make this process very fast ? I am expecting that we need to make fast process same as we are receiving response in websocket.
Last edited by a moderator: