code: def calculate_dates(self, dt):
          
          period_start, period_close = self.cal.open_and_close_for_session(
              self.cal.minute_to_session_label(dt),
          )
  
          # Align the market open and close times here with the execution times
          # used by the simulation clock. This ensures that scheduled functions
          # trigger at the correct times.
          self._period_start = self.cal.execution_time_from_open(period_start)
          self._period_close = self.cal.execution_time_from_close(period_close)
  
          self._period_end = self._period_start + self.offset - self._one_minute
docs: Given a date, find that day's open and period end (open + offset).