/// <summary> /// Example of using a custom aggregation function for standard deviation calculation. /// </summary> /// <param name="ericUSDStream"></param> /// <param name="outputConfig"></param> /// <param name="adapterStopSignal"></param> private static void standardDeviationExample(CepStream<StockQuote> cepStream, Application application) { var stddevCepStream = from w in cepStream.Where(e => e.FieldID == "Close") .HoppingWindow(TimeSpan.FromDays(7), TimeSpan.FromDays(1), HoppingWindowOutputPolicy.ClipToWindowEnd) select new StockQuote() { StockID = "ERIC", FieldID = "7-day Stddev", Value = w.StandardDeviation() }; runQuery(stddevCepStream, application); }
/// <summary> /// Example of window function /// </summary> /// <param name="cepStream"></param> /// <param name="outputConfig"></param> /// <param name="adapterStopSignal"></param> private static void avgExample(CepStream<StockQuote> cepStream, Application application) { var avgCepStream = from w in cepStream.Where(e => e.FieldID == "Close") .HoppingWindow(TimeSpan.FromDays(7), TimeSpan.FromDays(1), HoppingWindowOutputPolicy.ClipToWindowEnd) select new StockQuote() { StockID = "ERIC", FieldID = "7-day avg", Value = w.Avg(e => e.Value) }; runQuery(avgCepStream, application); }