This code is working well. I have hardcoded the refresh period as 1 second.
It creates 1sec. and 1 min. bars optionally as per bar period in settings.ini set as 1000 or 60000.
I tallied the results with Hourly statistics data from NOW. It is tallies to a large extent.
However, it is missing some ticks. (In every 1 crore nifty futures, 6000 to 20000 shares are missed). This happens because thread A is maintaining OHLC from data received in array. It creates one current and one previous bar for each scrip. If it receives 1 tic of one period and 1 tick of next period in the same array, it creates new current bar and data for first tick is lost as it is pushed to previous bar. This also creates slight 5, 10 paise deviation in OHLC and volume of bars.
Though this is acceptable in time frames of 3 min and above, I am not satisfied with it. Therefore I decided to go for option 2 of Tracerbullet.
It creates 1sec. and 1 min. bars optionally as per bar period in settings.ini set as 1000 or 60000.
I tallied the results with Hourly statistics data from NOW. It is tallies to a large extent.
However, it is missing some ticks. (In every 1 crore nifty futures, 6000 to 20000 shares are missed). This happens because thread A is maintaining OHLC from data received in array. It creates one current and one previous bar for each scrip. If it receives 1 tic of one period and 1 tick of next period in the same array, it creates new current bar and data for first tick is lost as it is pushed to previous bar. This also creates slight 5, 10 paise deviation in OHLC and volume of bars.
Though this is acceptable in time frames of 3 min and above, I am not satisfied with it. Therefore I decided to go for option 2 of Tracerbullet.
Please find the comments from Zerodha to a similar question asked.
Are you trying to capture the data for several scripts parallel ?
The issue may be due to Internet connection ? and not with the code.
http://www.traderji.com/brokers-trading-platforms/89121-zerodha-part-3-a-1031.html#post1088126