gs_quant.timeseries.statistics.product¶
- product(x, w=<gs_quant.timeseries.helper.Window object>)[source]¶
Rolling product of series over given window
- Parameters:
x (
Series
) – series: 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 product
Usage
Calculate the product of observations over a given rolling window. For each time, \(t\), returns the value of all observations from \(t-w+1\) to \(t\) multiplied together:
\(R_t = \prod_{i=t-w+1}^{t} X_i\)
where \(w\) is the size of the rolling window. If window is not provided, computes product over the full series
Examples
Generate price series and compute rolling sum over \(22\) observations
>>> prices = generate_series(100) >>> product(1+returns(prices))
See also