gs_quant.datetime.date.date_range

date_range(begin, end, calendars=(), week_mask=None)[source]

Construct a range of dates

Parameters:
  • begin (Union[int, date]) – Beginning date or int. An int will be interpreted as the number of business days before end (which must be a date)

  • end (Union[int, date]) – End date or int. An int will be interpreted as the number of business days after begin (which must be a date)

  • calendars (Union[str, Tuple[str, ...]]) – Calendars to use for holidays

  • week_mask (Optional[str]) – Which days are considered weekends (defaults to Saturday and Sunday)

Return type:

Iterable[date]

Returns:

A generator of dates

>>> import datetime as dt
>>> today = dt.date.today()
>>> dates = tuple(date_range(5, today))
>>>
>>> for date in date_range(dt.date(2019, 1, 1), dt.date(2019, 2, 1)):
>>>     print(date)