Functions.Sum
method · Functions · cAlgo.API
DesktopCLICloud
Calculates the sum of a data series, over the specified period.
Definition
public static double Sum(DataSeries series, int period)
Functions.Sum(series: DataSeries, period: int) -> float
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
series | DataSeries | DataSeries | DataSeries of which values are summed |
period | int | int | Period of values that are summed prior to current index |
Returns double — The sum of the series for the period
Examples
var volumeSum = Bars.TickVolumes.Sum(20);
Print("Tick volume of the last 20 bars: {0}", volumeSum);
volumeSum = Functions.Sum(api.Bars.TickVolumes, 20)
api.Print(f"Tick volume of the last 20 bars: {volumeSum}")