gs_quant.timeseries.analysis.compare

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

Compare two series or scalars against each other

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:

binary timeseries with the result of x relation y or the comparison of the given real numbers

Usage

Compare two series or scalar variables applying the given interpolation method in case indices of \(x\) and \(y\) differ. Returns a signal with values of 1, 0, or -1.

If \(X_t > Y_t\), then \(R_t = 1\). If \(X_t = Y_t\), then \(R_t = 0\). If \(X_t < Y_t\), then \(R_t = -1\).

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.