Traded value for the day in ticks

vineet_dhandhania
Hi,

I want to compute the volume weighted average price in time intervals (not for the entire day). For that I need either -
1) precise average_price, or
2) value traded for the day in each tick

The first is not available as can be learned from another thread (https://kite.trade/forum/discussion/4332/average-price-field-precision-only-up-to-2-decimals/p1).

Can you provide the second?

Thanks,
Vineet
  • rakeshr
    @vineet_dhandhania
    You can calculate volume traded for each tick from WebSocket Feed, by subtracting current tick volume to last tick volume data.
    {'volume': 35901,last_price': 4762.0, 'timestamp': datetime.datetime(2018, 7, 23, 16, 13, 19)}
    {'volume': 35903,last_price': 4763.0,'timestamp': datetime.datetime(2018, 7, 23, 16, 13, 20)}
    Here, volume traded for 1 tick is 2 (35903-35901).
  • vineet_dhandhania
    @rakeshr Thanks for replying. I already know what you mentioned. That is only 1 of the 2 needed inputs. Hence that doesn't solve my requirement.

    I want to compute the volume weighted average price for an interval. For that I would need either 1) precise average price (before and after the interval), or 2) Traded value (before and after the interval), in addition to the volume (before and after the interval). I hope I was able to make myself clearer this time.
  • rakeshr
    @vineet_dhandhania
    You can do summation multiplication of volume difference and last_price(use last_price,only if volume_difference > 0) and keep adding total volume with current tick volume(it will be divisor).Something like if volume_difference > 0:
    weighted_price=(volume_difference*last_price)+weighted_price
    total_volume=total_volume+volume_difference
    vwap=weighted_price/total volume
  • vineet_dhandhania
    vineet_dhandhania edited July 2018
    @rakeshr I was hoping there could be a solution that doesn't need computation for every tick. Anyway, thanks!
This discussion has been closed.