Receiving ticks late

trader_engineer
Hi

I am pretty new to algo trading, trying my hands with kite connect ticker SDK. I noticed that I am receiving ticks pretty late, sometime delay of even 7-8 seconds. I am not sure, if I am doing something wrong or its issue with my internet speed. I wanted to check with community, to see what kind of delay they normally experience.

Following is the code that I wrote for checking delays in tick

private static void initTicker()
{
ticker = new Ticker(MyAPIKey, MyAccessToken);

ticker.OnTick += OnTick;
ticker.OnReconnect += OnReconnect;
ticker.OnNoReconnect += OnNoReconnect;
ticker.OnError += OnError;
ticker.OnClose += OnClose;
ticker.OnConnect += OnConnect;

ticker.EnableReconnect(Interval: 10, Retries: 15);
ticker.Connect();

ticker.Subscribe(Tokens: Stocks.Values.ToArray());
ticker.SetMode(Tokens: Stocks.Values.ToArray(), Mode: Constants.MODE_FULL);
}

private static void OnTick(Tick tickData)
{

if (tickData.Timestamp.Value.AddSeconds(3) < DateTime.Now)
{
Logger.LogMessage(string.Format("*** Received Late Tick {0}, Time={1}, LTP={2}, Volume={3}, Buy={4}, Sell={5} . Count of late ticks={6}",
symbol, tickData.Timestamp.Value, tickData.LastPrice, tickData.Volume, tickData.BuyQuantity, tickData.SellQuantity, ++LateTickCount));
}
}
Tagged:
  • sujith
    You might be blocking the main thread. Make sure you don't do anything inside onTick or offload all processing to the secondary thread.
  • trader_engineer
    thanks for your response. I will try removing all additional code and just measure delays in ticks.
  • trader_engineer
    thanks Sujith. I measured tick data response time by getting rid of all extra code., and also running it on better VM from AWS (c5.xlarge). Now I am getting most ticks in same second or next. For about 1% of ticks there is delay more than 1 second. So this is good for now. Thanks for your suggestions.
Sign In or Register to comment.