'Schedules a function to be called according to some timed rules.
Parameters
func : callable[(context, data) -> None]
The function to execute when the rule is triggered.
date_rule : EventRule, optional
The rule for the dates to execute this function.
time_rule : EventRule, optional
The rule for the times to execute this function.
half_days : bool, optional
Should this rule fire on half days?
calendar : Sentinel, optional
Calendar used to reconcile date and time rules.
See Also
:class:`zipline.api.date_rules`
:class:`zipline.api.time_rules`'

@api_method
def schedule_function(self, func, date_rule=None, time_rule=None, half_days=True, calendar=None):

    if (isinstance(date_rule, (AfterOpen, BeforeClose)) and (not time_rule)):
        warnings.warn('Got    a    time    rule    for    the    second    positional    argument    date_rule.    You    should    use    keyword    argument    time_rule=    when    calling    schedule_function    without    specifying    a    date_rule', stacklevel=3)
    date_rule = (date_rule or date_rules.every_day())
    time_rule = ((time_rule or time_rules.every_minute()) if (self.sim_params.data_frequency == 'minute') else time_rules.every_minute())
    if (calendar is None):
        cal = self.trading_calendar
    elif (calendar is calendars.US_EQUITIES):
        cal = get_calendar('NYSE')
    elif (calendar is calendars.US_FUTURES):
        cal = get_calendar('us_futures')
    else:
        raise ScheduleFunctionInvalidCalendar(given_calendar=calendar, allowed_calendars='[calendars.US_EQUITIES,    calendars.US_FUTURES]')
    self.add_event(make_eventrule(date_rule, time_rule, cal, half_days), func)
