Like Grid Aggregate methods, the Java SequenceIterator Window Aggregate methods take an integer interval argument and produce a result sequence containing the calculated aggregate for each interval. The difference in how Window Aggregate methods determine their sliding window interval is described in the Window versus Grid Aggregate page. The result of all Window Aggregate methods is returned in the result sequence as the calculated aggregate for each interval. As with Grid Aggregate methods, the object's sequence is split into intervals based on the value of the interval argument (of type
uint8
) which determines the maximum number of elements in the group, though there may be fewer. So the input sequence will be divided into blocks of interval elements on which the operation is performed.
SequenceIterator windowAggMax(int interval) Returns the sequence with the maximum value for each window of elements SequenceIterator windowAggMin(int interval) Returns the sequence with the minimum value for each window of elements SequenceIterator windowAggSum(int interval) Returns the sequence with the sum of each window of elements SequenceIterator windowAggAvg(int interval) Returns the sequence with the average of each window of elements SequenceIterator windowAggVar(int interval) Returns the sequence with the variance of each window of elements SequenceIterator windowAggVarSamp(int interval) Returns the sequence with the sample variance of each window of elements SequenceIterator windowAggDev(int interval) Returns the sequence with the standard deviation of each window of elements SequenceIterator windowAggDevSamp(int interval) Returns the sequence with the sample standard deviation of each window of elements SequenceIterator windowAggEma(int period) Returns the Exponential Moving Average (EMA) in the first sequence element (using the algorithm described in the Window Aggregate EMA page)
SequenceIterator windowAggAtr(int period) Returns the Average True Range (ATR) in the first sequence element (using the True Range algorithm described in the Window Aggregate ATR page) Example
Following is an example code snippet demonstrating a window aggregate method:
public static void windowAggregate(Connection con) { con.startTransaction(Database.TransactionType.ReadOnly); Cursor<Quote> cursor = new Cursor<Quote>(con, Quote.class, "symbol"); for (Quote quote : cursor) { SequenceIterator winAvg20 = quote.close.iterator().windowAggAvg(20); SequenceIterator winAvg5 = quote.close.iterator().windowAggAvg(5); SequenceIterator cross = quote.day.map(winAvg20.sub(winAvg5).cross(1)); ... } con.commitTransaction(); }