All Cumulative Aggregate C functions take a single input sequence argument and produce a result sequence. The result sequence is either of the same type as the input sequence or of type
double, depending on the operation performed. The value of each element in the result is the outcome of the specified operation applied to all preceding elements.The function signatures follow this general form:
MCO_RET mco_seq_cum_agg_operation_TYPE( mco_seq_iterator_h result, mco_seq_iterator_h input );where
TYPEis one of the data types listed in the Analytics Functions page, and operation is one of the following:mco_seq_cum_agg_max_TYPE()Returns a result sequence of the sameTYPEcontaining the cumulative maximum: each element is the maximum value of all preceding elements.mco_seq_cum_agg_min_TYPE()Returns a result sequence of the sameTYPEcontaining the cumulative minimum: each element is the minimum value of all preceding elements.mco_seq_cum_agg_sum_TYPE()Returns a result sequence of the sameTYPEcontaining the cumulative sum: each element is the sum of all preceding elements.mco_seq_cum_agg_prd_TYPE()Returns a result sequence of the sameTYPEcontaining the cumulative product: each element is the product of all preceding elements.mco_seq_cum_agg_avg_TYPE()Returns adoubleresult sequence containing the cumulative average: each element is the average of all preceding elements.mco_seq_cum_agg_var_TYPE()Returns adoubleresult sequence containing the cumulative variance: each element is the variance of all preceding elements.mco_seq_cum_agg_var_samp_TYPE()Returns adoubleresult sequence containing the cumulative sample variance: each element is the sample variance of all preceding elements.mco_seq_cum_agg_dev_TYPE()Returns adoubleresult sequence containing the cumulative standard deviation: each element is the standard deviation of all preceding elements.mco_seq_cum_agg_dev_samp_TYPE()Returns adoubleresult sequence containing the cumulative sample standard deviation: each element is the sample standard deviation of all preceding elements.Example
The following code snippet demonstrates the use of a cumulative aggregate function:
{ mco_trans_h trans; mco_cursor_h quote_cursor; Quote quote; mco_seq_iterator_h close_iterator, max_iterator; MCO_RET rc; ... for (rc = mco_cursor_first(trans, "e_cursor); rc != MCO_S_CURSOR_END; rc = mco_cursor_next(trans, "e_cursor)) { Quote_from_cursor(trans, "e_cursor, "e); Quote_close_iterator("e, &close_iterator); mco_seq_cum_agg_max_float(&max_iterator, &close_iterator); ... } ... }