Schedule function is not working correctly!

While calling the schedule function, i want to call the function in every 15 minutes.



Following is the code.

 

for i in (1 ,360, 15):
schedule_function(
run_strategy,
date_rules.every_day(),
time_rules.market_open(minutes= i))

def run_strategy(context, data):
    print(get_datetime())

The output which is coming is only for 3 time stamps. 
 
# Output
2021-09-08 09:15:59+00:00
2021-09-08 09:29:59+00:00
2021-09-08 15:14:59+00:00

Can anyone figure out where the fault is with the code?
Thanks in advance

Hi Tanul



Please try out the below code:

from zipline.api import(    symbol,
                            order_target_percent,
                            schedule_function,
                            date_rules,
                            time_rules,
                            get_datetime
                       )

def initialize(context):
    """
    A function to define things to do at the start of the strategy
    """

    for i in range(1, 375, 15):
        schedule_function(
            run_strategy,
            date_rules.every_day(),
            time_rules.market_open(minutes=i)
        )

def run_strategy(context, data):
    print(get_datetime())

I believe you intended your code wrong.



Hope the above code helps.