Hi David
The best option for this will be a real time subscriber process, subscribed to your tickerplant to track the necessary data and perform the calculations of these metrics as required.
We have developed a real time subscriber to achieve this. I have attached the code for this process. This code will work with a standard kdb+tick setup (or with the kdb+ framework setup you mentioned).
The subscriber will subscribe to the TP, and will recover historical messages by replaying the log file up until the point of subsciption.
In order to get this up & running, you will need to modify the connection details for the TP in the init function. You may also need to modify the column names in the following line in the upd function to match the schema for your trade table:
x: flip `time`sym`price`size`stop`cond`ex!x
The windows for calcuation of the metrics can be defined in the "windows" variable at the top of the file, though the subscriber is flexible enough to calculate VWAP + TWAP over any period, e.g. you could also use it to calculate the VWAP/TWAP from 20 minutes ago until 5 minutes to go.
To obtain the metrics at any time, call the metrics[] function with a list of syms as the argument e.g. metrics[`AAPL`MSFT]
You also posted this on our other google group - we’ll post a
slightly modified version over there.
Hope this helps
Jonathon