gs_quant.timeseries.algebra.if_

if_(flags, x, y)[source]

Returns a series s. For i in the index of flags, s[i] = x[i] if flags[i] == 1 else y[i].

Parameters:
  • flags (Series) – series of 1s and 0s

  • x (Union[Series, float]) – values to use when flag is 1

  • y (Union[Series, float]) – values to use when flag is 0

Return type:

Series

Returns:

result series

Usage

Returns a series based off the given conditional series. If the condition is true it shows the first series’s value else it shows the second series’s value.

PlotTool Example

if(SPX.spot() > 4000, SPX.spot(), GSTHHVIP.spot())

The above expression would show SPX.spot() if the spot price is above 4000 else it shows GSTHHVIP.spot().