gs_quant.timeseries.statistics.sum_¶
- sum_(x, w=<gs_quant.timeseries.helper.Window object>)[source]¶
Rolling sum of series over given window
- Parameters:
x (
Union
[Series
,List
[Series
]]) – series: a timeseries or an array of timeseriesw (
Union
[Window
,int
,str
]) – Window or int: size of window and ramp up to use. e.g. Window(22, 10) where 22 is the window size and 10 the ramp up value. If w is a string, it should be a relative date like ‘1m’, ‘1d’, etc. Window size defaults to length of series.
- Return type:
Series
- Returns:
timeseries of rolling sum
Usage
Calculate the sum of observations over a given rolling window.
If \(x\) is a series:
\(R_t = \sum_{i=t-w+1}^{t} X_i\)
where \(w\) is the size of the rolling window.
If \(x\) is an array of series:
\(R_t = \sum_{i=t-w+1}^{t} \sum_{j=1}^{n} X_{ij}\)
where \(w\) is the size of the rolling window and \(n\) is the number of series
If window is not provided, computes sum over the full series. If the window size is greater than the available data, will return sum of available values.
Examples
Generate price series and compute rolling sum over \(22\) observations
>>> prices = generate_series(100) >>> sum_(prices, 22)
See also