It looks like you're new here. If you want to get involved, click one of these buttons!
'instrument_token': 53490439,
'mode': 'full',
'volume': 12510,
'last_price': 4084.0,
'average_price': 4086.55,
'last_quantity': 1,
I have used the following computations for every tick in one-minute duration:volume = volume + tick['volume']
volume = volume + tick['last_quantity']
When you receive the first tick of the minute, you should set your local volume variable to 0 and keep taking the delta between two ticks volume and add on to your localvolume variable till your minute gets over.
I am not sure if I understood you completely. As per your description, for following PNB ticks, I would:
volume = 0 # Initial value last_tick_qty = 799 # Save current tick's last qty
volume = 0 # volume does not change volume = volume + abs(last_tick_qty - 749)
last_tick_qty = 749
Is this how I should compute a given period's volume? I am lost here. Please help me understand with an example. Thank you.
So lets say you have a 1 minute chart volume to be calculated. And its now 9:15:01 and the first tick comes.
Volume field in that tick is 200. So your candle_volume_field = Volume field.
Next tick comes at 9:15:31 where Volume field is 420.
So your candle_volume_field = Volume field. (aka 420)
Now say at 09:16:01 the first tick for the second minute comes as volume field here is 600
So now your candle_volume_field = volume - Previous candle_volume_field
ie. 600-420 = 180
And this goes on now for that minute. WHen the minute changes again, the same logic will apply.