vwap
vwap — aggregate function that returns the volume-weighted average price.
DESCRIPTION
This function computes a value for the specified fields in each record from the base
table and returns the volume-weighted average price. The argument field types must be
of type double, or coercible to double. The returned price is type double
.
EXAMPLE
This example shows how to use dynamic aggregation to find the volume weighted average price of the values in two columns. In the Hello LiveView sample, create a query that finds the VWAP of the lastSoldPrice field weighted by the quantityRemaining field from the ItemSales table, grouping by Item. Follow these steps:
-
In LiveView Desktop connected to a server running the Hello LiveView sample, select the ItemsSales table from the Tables pane of the LiveView Tables view.
-
In the Select field, enter:
Item, vwap(lastSoldPrice,quantityRemaining) AS VWAP
-
In the Query field, enter the following:
group by Item
-
Click
.
The query results open in a grid view. LiveView Server recalculates the VWAP value whenever the rows returned by the query predicate change.
SEE ALSO
This LiveView aggregate function is based on the vwap aggregate function in the StreamBase expression language.