class_docstr: Defines an array of dates specified by a regular schedule.
docstr: Initializes the schedule.
  
  Initializes a schedule with a given tenor, date range and holiday calendar.
  
  A schedule is an increasing sequence of dates at a regular interval subject
  to holiday adjustments.
  
  The rules for schedule generation (accessed via the `dates()` method)
  are as follows.
  
  (a) If `backward=False`, take `start_date` and add `tenor` multiplied by
    0, 1, 2, etc. until the resulting date is greater than `end_date`.
  (b) If `backward=True`, take `end_date` and subtract `tenor` multiplied by
    0, 1, 2, etc. until the resulting date is smaller than `start_date`.
    Ensure that the result is in ascending order.
  (c) Both `start_date` and `end_date` are included, even if the distance
    between then is not an integer number of tenor periods.
  (d) If `holiday_calendar` is specified, roll all the dates according to
    `roll_convention`. The rolling includes `start_date` and `end_date` when
    they are part of resulting schedule. Thus if `start_date` or `end_date`
    fall on holidays, they will change and may go out of the
    [`start_date`, `end_date`] interval.
  
  Note that `tenor = PeriodType.DAY` is treated as an actual day, not as
  a business day. So a schedule with `tenor = days(7)` is the same
  as one with `tenor = week()`.
  
  The `dates()` can create multiple schedules simultaneously.
  The start and end dates may have any (compatible) shape.
  The `DateTensor` returned by `dates()` has the shape
  `start_date.shape + (n,)`, where `n` is the maximum length of schedules in
  the batch. If schedules have different lengths, the extra elements will be
  padded with extra `end_date` elements at the end, if `backward=False`
  and with extra `start_date` elements in the beginning if
  `backward=True`. In all cases each schedule in the batch is monotonic.
  
  The following examples demonstrate the batch and non-batch usage.
  
  #### Example Usage (Non-batch)
  
  ```python
    start_date = datetime.dates_from_tuples([(2020, 1, 18)])
    end_date = datetime.dates_from_tuples([(2021, 3, 25)])
    tenor = datetime.months(3)
    backward = False
    holiday_calendar = dates.HolidayCalendar(start_year=2020, end_year=2021)
    roll_convention = dates.BusinessDayConvention.FOLLOWING
    schedule = datetime.PeriodicSchedule(
        start_date=start_date,
        end_date=end_date,
        tenor=tenor,
        holiday_calendar=holiday_calendar,
        roll_convention=datetime.BusinessDayConvention.FOLLOWING,
        backward=backward).dates()
    # schedule is a DateTensor of
    # [[(2020, 1, 18), (2020, 4, 20), (2020, 7, 20), (2020, 10, 19),
    #   (2021, 1, 18), (2021, 3, 25)]] for backward = False and
    # [[(2020, 1, 18), (2020, 3, 25), (2020, 6, 25), (2020, 9, 25),
    #   (2020, 12, 25), (2021, 3, 25)]] for backward = True.
  ```
  
  The following example demonstrates this batching property.
  
  #### Example Usage (Batch)
  
  ```python
    start_date = datetime.dates_from_tuples([(2020, 1, 15), (2020, 4, 15)])
    end_date = datetime.dates_from_tuples([(2021, 3, 31), (2021, 1, 1)])
    tenor = datetime.months([4, 3])
    schedule = datetime.PeriodicSchedule(
        start_dates,
        end_dates,
        tenors,
        dates.HolidayCalendar(start_year=2020, end_year=2021),
        roll_convention=datetime.BusinessDayConvention.FOLLOWING,
        backward=False).dates()
    # Returns DateTensor of
    # [[(2020, 1, 15), (2020, 5, 15), (2020, 9, 15), (2021, 1, 15),
    #   (2021, 3, 31)],
    # [(2020, 4, 15), (2020, 7, 15), (2020, 10, 15), (2021, 1, 1),
    #  (2021, 1, 1)]].
  ```
  
  Args:
    start_date: `DateTensor`. Defines the lower boundary of schedule. If
      `backward=True` must be broadcastable to `end_date`, otherwise has
      arbitrary shape.
    end_date: `DateTensor`. Defines the upper boundary of the schedule.
      If `backward=False` must be broadcastable to `start_date`, otherwise has
      arbitrary shape.
    tenor: `PeriodTensor`. Defines the frequency of the schedule. Must
      be broadcastable to `start_date` if `backward=False`, and to `end_date`
      if `backward=True`.
    holiday_calendar: `dates.HolidayCalendar`. If `None`, the dates in the
      schedule will not be rolled to business days.
    roll_convention: BusinessDayConvention. Defines how dates in the schedule
      should be rolled to business days if they fall on holidays. Ignored if
      `holiday_calendar = None`.
      Default value: BusinessDayConvention.NONE (i.e. no rolling).
    backward: Python `bool`. Whether to build the schedule from the
      `start_date` moving forwards or from the `end_date` and moving
      backwards.
    end_of_month: Python `bool`. If `True`, shifts all dates in schedule to
      the ends of corresponding months, if `start_date` or `end_date` (
      depending on `backward`) is at the end of a month. The shift is applied
      before applying `roll_convention`. In the batched case, only those
      schedules in a batch, whose corresponding `start_date` (or `end_date`)
      are at ends of months, will be shifted.
docstr_tok: ["Initializes","the","schedule",".","Initializes","a","schedule","with","a","given","tenor",",","date","range","and","holiday","calendar",".","A","schedule","is","an","increasing","sequence","of","dates","at","a","regular","interval","subject","to","holiday","adjustments",".","The","rules","for","schedule","generation","(","accessed","via","the","`","dates","(",")","`","method",")","are","as","follows",".","(","a",")","If","`","backward=False","`",",","take","`","start_date","`","and","add","`","tenor","`","multiplied","by","0",",","1",",","2",",","etc",".","until","the","resulting","date","is","greater","than","`","end_date","`",".","(","b",")","If","`","backward=True","`",",","take","`","end_date","`","and","subtract","`","tenor","`","multiplied","by","0",",","1",",","2",",","etc",".","until","the","resulting","date","is","smaller","than","`","start_date","`",".","Ensure","that","the","result","is","in","ascending","order",".","(","c",")","Both","`","start_date","`","and","`","end_date","`","are","included",",","even","if","the","distance","between","then","is","not","an","integer","number","of","tenor","periods",".","(","d",")","If","`","holiday_calendar","`","is","specified",",","roll","all","the","dates","according","to","`","roll_convention","`",".","The","rolling","includes","`","start_date","`","and","`","end_date","`","when","they","are","part","of","resulting","schedule",".","Thus","if","`","start_date","`","or","`","end_date","`","fall","on","holidays",",","they","will","change","and","may","go","out","of","the","[","`","start_date","`",",","`","end_date","`","]","interval",".","Note","that","`","tenor","=","PeriodType.DAY","`","is","treated","as","an","actual","day",",","not","as","a","business","day",".","So","a","schedule","with","`","tenor","=","days","(","7",")","`","is","the","same","as","one","with","`","tenor","=","week","(",")","`",".","The","`","dates","(",")","`","can","create","multiple","schedules","simultaneously",".","The","start","and","end","dates","may","have","any","(","compatible",")","shape",".","The","`","DateTensor","`","returned","by","`","dates","(",")","`","has","the","shape","`","start_date.shape","+","(","n",",",")","`",",","where","`","n","`","is","the","maximum","length","of","schedules","in","the","batch",".","If","schedules","have","different","lengths",",","the","extra","elements","will","be","padded","with","extra","`","end_date","`","elements","at","the","end",",","if","`","backward=False","`","and","with","extra","`","start_date","`","elements","in","the","beginning","if","`","backward=True","`",".","In","all","cases","each","schedule","in","the","batch","is","monotonic",".","The","following","examples","demonstrate","the","batch","and","non-batch","usage",".","#","#","#","#","Example","Usage","(","Non-batch",")","``","`","python","start_date","=","datetime.dates_from_tuples","(","[","(","2020",",","1",",","18",")","]",")","end_date","=","datetime.dates_from_tuples","(","[","(","2021",",","3",",","25",")","]",")","tenor","=","datetime.months","(","3",")","backward","=","False","holiday_calendar","=","dates.HolidayCalendar","(","start_year=2020",",","end_year=2021",")","roll_convention","=","dates.BusinessDayConvention.FOLLOWING","schedule","=","datetime.PeriodicSchedule","(","start_date=start_date",",","end_date=end_date",",","tenor=tenor",",","holiday_calendar=holiday_calendar",",","roll_convention=datetime.BusinessDayConvention.FOLLOWING",",","backward=backward",")",".dates","(",")","#","schedule","is","a","DateTensor","of","#","[","[","(","2020",",","1",",","18",")",",","(","2020",",","4",",","20",")",",","(","2020",",","7",",","20",")",",","(","2020",",","10",",","19",")",",","#","(","2021",",","1",",","18",")",",","(","2021",",","3",",","25",")","]","]","for","backward","=","False","and","#","[","[","(","2020",",","1",",","18",")",",","(","2020",",","3",",","25",")",",","(","2020",",","6",",","25",")",",","(","2020",",","9",",","25",")",",","#","(","2020",",","12",",","25",")",",","(","2021",",","3",",","25",")","]","]","for","backward","=","True",".","``","`","The","following","example","demonstrates","this","batching","property",".","#","#","#","#","Example","Usage","(","Batch",")","``","`","python","start_date","=","datetime.dates_from_tuples","(","[","(","2020",",","1",",","15",")",",","(","2020",",","4",",","15",")","]",")","end_date","=","datetime.dates_from_tuples","(","[","(","2021",",","3",",","31",")",",","(","2021",",","1",",","1",")","]",")","tenor","=","datetime.months","(","[","4",",","3","]",")","schedule","=","datetime.PeriodicSchedule","(","start_dates",",","end_dates",",","tenors",",","dates.HolidayCalendar","(","start_year=2020",",","end_year=2021",")",",","roll_convention=datetime.BusinessDayConvention.FOLLOWING",",","backward=False",")",".dates","(",")","#","Returns","DateTensor","of","#","[","[","(","2020",",","1",",","15",")",",","(","2020",",","5",",","15",")",",","(","2020",",","9",",","15",")",",","(","2021",",","1",",","15",")",",","#","(","2021",",","3",",","31",")","]",",","#","[","(","2020",",","4",",","15",")",",","(","2020",",","7",",","15",")",",","(","2020",",","10",",","15",")",",","(","2021",",","1",",","1",")",",","#","(","2021",",","1",",","1",")","]","]",".","``","`","Args",":","start_date",":","`","DateTensor","`",".","Defines","the","lower","boundary","of","schedule",".","If","`","backward=True","`","must","be","broadcastable","to","`","end_date","`",",","otherwise","has","arbitrary","shape",".","end_date",":","`","DateTensor","`",".","Defines","the","upper","boundary","of","the","schedule",".","If","`","backward=False","`","must","be","broadcastable","to","`","start_date","`",",","otherwise","has","arbitrary","shape",".","tenor",":","`","PeriodTensor","`",".","Defines","the","frequency","of","the","schedule",".","Must","be","broadcastable","to","`","start_date","`","if","`","backward=False","`",",","and","to","`","end_date","`","if","`","backward=True","`",".","holiday_calendar",":","`","dates.HolidayCalendar","`",".","If","`","None","`",",","the","dates","in","the","schedule","will","not","be","rolled","to","business","days",".","roll_convention",":","BusinessDayConvention",".","Defines","how","dates","in","the","schedule","should","be","rolled","to","business","days","if","they","fall","on","holidays",".","Ignored","if","`","holiday_calendar","=","None","`",".","Default","value",":","BusinessDayConvention.NONE","(","i.e",".","no","rolling",")",".","backward",":","Python","`","bool","`",".","Whether","to","build","the","schedule","from","the","`","start_date","`","moving","forwards","or","from","the","`","end_date","`","and","moving","backwards",".","end_of_month",":","Python","`","bool","`",".","If","`","True","`",",","shifts","all","dates","in","schedule","to","the","ends","of","corresponding","months",",","if","`","start_date","`","or","`","end_date","`","(","depending","on","`","backward","`",")","is","at","the","end","of","a","month",".","The","shift","is","applied","before","applying","`","roll_convention","`",".","In","the","batched","case",",","only","those","schedules","in","a","batch",",","whose","corresponding","`","start_date","`","(","or","`","end_date","`",")","are","at","ends","of","months",",","will","be","shifted","."]
code: def __init__(
      self,
      *,
      start_date,
      end_date,
      tenor,
      holiday_calendar=None,
      roll_convention=constants.BusinessDayConvention.NONE,
      backward=False,
      end_of_month=False,
  ):
      """Initializes the schedule.
  
      Initializes a schedule with a given tenor, date range and holiday calendar.
  
      A schedule is an increasing sequence of dates at a regular interval subject
      to holiday adjustments.
  
      The rules for schedule generation (accessed via the `dates()` method)
      are as follows.
  
      (a) If `backward=False`, take `start_date` and add `tenor` multiplied by
        0, 1, 2, etc. until the resulting date is greater than `end_date`.
      (b) If `backward=True`, take `end_date` and subtract `tenor` multiplied by
        0, 1, 2, etc. until the resulting date is smaller than `start_date`.
        Ensure that the result is in ascending order.
      (c) Both `start_date` and `end_date` are included, even if the distance
        between then is not an integer number of tenor periods.
      (d) If `holiday_calendar` is specified, roll all the dates according to
        `roll_convention`. The rolling includes `start_date` and `end_date` when
        they are part of resulting schedule. Thus if `start_date` or `end_date`
        fall on holidays, they will change and may go out of the
        [`start_date`, `end_date`] interval.
  
      Note that `tenor = PeriodType.DAY` is treated as an actual day, not as
      a business day. So a schedule with `tenor = days(7)` is the same
      as one with `tenor = week()`.
  
      The `dates()` can create multiple schedules simultaneously.
      The start and end dates may have any (compatible) shape.
      The `DateTensor` returned by `dates()` has the shape
      `start_date.shape + (n,)`, where `n` is the maximum length of schedules in
      the batch. If schedules have different lengths, the extra elements will be
      padded with extra `end_date` elements at the end, if `backward=False`
      and with extra `start_date` elements in the beginning if
      `backward=True`. In all cases each schedule in the batch is monotonic.
  
      The following examples demonstrate the batch and non-batch usage.
  
      #### Example Usage (Non-batch)
  
      ```python
        start_date = datetime.dates_from_tuples([(2020, 1, 18)])
        end_date = datetime.dates_from_tuples([(2021, 3, 25)])
        tenor = datetime.months(3)
        backward = False
        holiday_calendar = dates.HolidayCalendar(start_year=2020, end_year=2021)
        roll_convention = dates.BusinessDayConvention.FOLLOWING
        schedule = datetime.PeriodicSchedule(
            start_date=start_date,
            end_date=end_date,
            tenor=tenor,
            holiday_calendar=holiday_calendar,
            roll_convention=datetime.BusinessDayConvention.FOLLOWING,
            backward=backward).dates()
        # schedule is a DateTensor of
        # [[(2020, 1, 18), (2020, 4, 20), (2020, 7, 20), (2020, 10, 19),
        #   (2021, 1, 18), (2021, 3, 25)]] for backward = False and
        # [[(2020, 1, 18), (2020, 3, 25), (2020, 6, 25), (2020, 9, 25),
        #   (2020, 12, 25), (2021, 3, 25)]] for backward = True.
      ```
  
      The following example demonstrates this batching property.
  
      #### Example Usage (Batch)
  
      ```python
        start_date = datetime.dates_from_tuples([(2020, 1, 15), (2020, 4, 15)])
        end_date = datetime.dates_from_tuples([(2021, 3, 31), (2021, 1, 1)])
        tenor = datetime.months([4, 3])
        schedule = datetime.PeriodicSchedule(
            start_dates,
            end_dates,
            tenors,
            dates.HolidayCalendar(start_year=2020, end_year=2021),
            roll_convention=datetime.BusinessDayConvention.FOLLOWING,
            backward=False).dates()
        # Returns DateTensor of
        # [[(2020, 1, 15), (2020, 5, 15), (2020, 9, 15), (2021, 1, 15),
        #   (2021, 3, 31)],
        # [(2020, 4, 15), (2020, 7, 15), (2020, 10, 15), (2021, 1, 1),
        #  (2021, 1, 1)]].
      ```
  
      Args:
        start_date: `DateTensor`. Defines the lower boundary of schedule. If
          `backward=True` must be broadcastable to `end_date`, otherwise has
          arbitrary shape.
        end_date: `DateTensor`. Defines the upper boundary of the schedule.
          If `backward=False` must be broadcastable to `start_date`, otherwise has
          arbitrary shape.
        tenor: `PeriodTensor`. Defines the frequency of the schedule. Must
          be broadcastable to `start_date` if `backward=False`, and to `end_date`
          if `backward=True`.
        holiday_calendar: `dates.HolidayCalendar`. If `None`, the dates in the
          schedule will not be rolled to business days.
        roll_convention: BusinessDayConvention. Defines how dates in the schedule
          should be rolled to business days if they fall on holidays. Ignored if
          `holiday_calendar = None`.
          Default value: BusinessDayConvention.NONE (i.e. no rolling).
        backward: Python `bool`. Whether to build the schedule from the
          `start_date` moving forwards or from the `end_date` and moving
          backwards.
        end_of_month: Python `bool`. If `True`, shifts all dates in schedule to
          the ends of corresponding months, if `start_date` or `end_date` (
          depending on `backward`) is at the end of a month. The shift is applied
          before applying `roll_convention`. In the batched case, only those
          schedules in a batch, whose corresponding `start_date` (or `end_date`)
          are at ends of months, will be shifted.
      """
      if end_of_month and tenor.period_type() not in [
          constants.PeriodType.MONTH,
          constants.PeriodType.YEAR,
      ]:
          raise ValueError(
              "end_of_month may only be used with tenors of PeriodType.MONTH or "
              "PeriodType.YEAR"
          )
  
      self._start_date = start_date
      self._end_date = end_date
      self._tenor = tenor
      self._holiday_calendar = holiday_calendar
      self._roll_convention = roll_convention
      self._backward = backward
      self._end_of_month = end_of_month
  
imports: import tensorflow.compat.v2
  from tf_quant_finance.datetime import constants
  from tf_quant_finance.datetime import date_tensor
label_desc: Use image node_id 1 to create a new PeriodicSchedule object  with example: obj = PeriodicSchedule()