gs_quant.timeseries.datetime.date_range

date_range(x, start_date, end_date, weekdays_only=False)[source]

Create a time series from a (sub-)range of dates in an existing time series.

Parameters:
  • x (Series) – time series

  • start_date (Union[date, int]) – start date for the sliced time series. If integer, number of observations after the first

  • end_date (Union[date, int]) – end date for the sliced time series. If integer, number of observations before the last

  • weekdays_only (bool) – whether to include only weekdays in the sliced ranges

Return type:

Series

Returns:

sliced time series

Usage

Returns a restricted (“sliced”) time series based on start and end dates:

\(Y_t = R_t |_{start < t < end}\)

Examples

Slice the first and last week of a time series:

>>> series = generate_series(100)
>>> sliced_series = date_range(series,7,7)

create time series with the absolute date:

>>> date_range(series, Date(2021,1,1), Date(2021,12,30))

See also

day() :func: lag