Help with aggregation query to calculate relative volume

Relative Volume (often times called RVOL) is an indicator that tells traders how current trading volume is compared to past trading volume over a given period.

Hello guys,

I was wondering if someone can point me to the right direction. I am trying to calculate the mentioned metrics and I'm a bit stuck with how to calculate the difference between a current value at time T and an average value calculated from X days before to yesterday (T-X -> T-1)

My documents look like this:

Epic Date Total volume
ABC 2020/08/01 @ 08:05:00 100
ABC 2020/08/02 @ 08:05:00 50
ABC 2020/08/03 @ 08:05:00 10

Steps I am trying to achieve:

  1. Calculate the average value for last X days on field Volume grouped by time component. (What is the average on Volume for the last X days every day at the time 08:05 for example) I know how to do this part.
  2. Calculate the difference between today's value and value acquired in step 1. I don't know how to do this part.

Is this something that Serial Differencing can help me with? Although I do not aggregate using a date_histogram. I aggregate only using Hour and Minute time component.

Thank you for any suggestions

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.