It looks like you're new here. If you want to get involved, click one of these buttons!
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.
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.