How to perform aggregate calculations (such as VWAP and TWAP) in StreamBase

How to perform aggregate calculations (such as VWAP and TWAP) in StreamBase

book

Article ID: KB0076104

calendar_today

Updated On:

Products Versions
TIBCO Streaming -

Description

How to perform aggregate calculations such as VWAP and TWAP in StreamBase.

Issue/Introduction

How to perform aggregate calculations (such as VWAP and TWAP) in StreamBase

Resolution

Many of these functions are provided in the StreamBase Expression Language. Please see the "Aggregate Functions: Statistical Calculations" reference in the Help under..

StreamBase Documentation > StreamBase References > StreamBase Expression Language Functions
  • For VWAP, use the vwap() aggregate function. 
  • For TWAP, use the avg() function over a time-based aggregate window. 

The normal use of these functions is within the Aggregate Operator.  If you need more precise control over the data window (e.g. excluding specific items or varying the window size), then these functions may also be used in Query operators using data from a Query Table. 

More complex calculations can be performed by building up from the supplied statistical functions. Others may need to be programmed, either as aggregate functions (for use in the Aggregate and Query Operators), or as their own Custom Java Operators.