gs_quant.timeseries.algebra.add

add(x, y, method=Interpolate.STEP)[source]

Add two series or scalars

Parameters:
  • x (Union[Series, Real]) – timeseries or scalar

  • y (Union[Series, Real]) – timeseries or scalar

  • method (Interpolate) – interpolation method (default: step). Only used when both x and y are timeseries

Return type:

Union[Series, Real]

Returns:

timeseries of x + y or sum of the given real numbers

Usage

Add two series or scalar variables with the given interpolation method

\(R_t = X_t + Y_t\)

Alignment operators:

Method

Behavior

intersect

Resultant series only has values on the intersection of dates. Values for dates present in only one series will be ignored

nan

Resultant series has values on the union of dates in both series. Values for dates only available in one series will be treated as nan in the other series, and therefore in the resultant series

zero

Resultant series has values on the union of dates in both series. Values for dates only available in one series will be treated as zero in the other series

step

Resultant series has values on the union of dates in both series. Values for dates only available in one series will be interpolated via step function in the other series

time

Resultant series have values on the union of dates / times. Missing values surrounded by valid values will be interpolated given length of interval. Input series must use DateTimeIndex.

Examples

Add two series:

>>> a = generate_series(100)
>>> b = generate_series(100)
>>> add(a, b, Interpolate.STEP)

See also

subtract()