Stock / Futures opening price issue

prasad_n_k
Hi,

I am facing issue in getting the opening price of the stock/ futures in the ticker... Can someone guide me when should the ticker be invoked to get the correct opening price. Currently, I am waiting till 09:15 for my code inside the ticker to execute.... I have code something like below in C#.
private void OnTick(Tick tickData)
{
try
{
DateTime currentTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, AppConstants.INDIAN_ZONE);
DateTime startTime = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, 9, 15, 0);
DateTime endTime = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, 15, 31, 0);

int startTimeCompare = TimeSpan.Compare(currentTime.TimeOfDay, startTime.TimeOfDay);
int endTimeCompare = TimeSpan.Compare(currentTime.TimeOfDay, endTime.TimeOfDay);

if (startTimeCompare == 1 && endTimeCompare == -1)
{
// My coding logic inside the ticker...
......
}
}
}
Apparently, the above logic is creating issue for accurately capturing the stock / futures opening price.

So I have below question
1. Do I need to even have check on start time inside ticker... or ticker callback function gets executed only when first tick is received for stocks / futures
2. If the above logic for time check is correct, then do I need to start checking the prices before 09:15 so that any packet before 09:15 is not lost (pre market session )

Any help to resolve my opening price issue is greatly appreciated as this has made my coding strategy gone for toss :smiley:

Regards,
Prasad Koranne

  • sujith
    If you are looking at the liquid instrument then the first LTP of the day will be decided at around 09:07 to 09:08 AM in the pre-market session which is the open price for the day.
    I don't think adding timing to get open price makes sense.
    You can just keep listening to ticks and the open price information is sent in every tick that is streamed. You may as well check the tick timestamp to make sure that the tick is today's.
    Kite Ticker caches one tick it receives so that it can serve a tick immediately when someone subscribes to a token. So you may have to check that the tick is today's. In the case of liquid instruments, I don't think you need this.
This discussion has been closed.