Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
help with schedule_function

I want to use schedule_function twice, calling two different functions at different schedule.
Here func_A and func_B are two functions:

schedule_function(func_A, date_rules.every_day(), time_rules.market_open(hours=1))  
schedule_function(func_B, date_rules.every_day(), time_rules.market_open(hours=1, minutes=20))  

However, when func_B is called, schedule_function keeps only calling func_B and stops calling func_A.
It works normally if func_A and func_B are exactly the same though.

5 responses

@Igor,

when func_B is called, schedule_function keeps only calling func_B and stops calling func_A

I do not see that problem.

# buy_at_open - sell_before_close

def initialize(context):  
    schedule_function(buy_at_open, date_rules.every_day(), time_rules.market_open())  
    schedule_function(sell_before_close, date_rules.every_day(), time_rules.market_close(minutes = 10), True)  

def buy_at_open(context, data):  
    print("-----buy_at_open-----")  

def sell_before_close(context,data):  
    print("-----sell_before_close-----")  

Can you share the full code with the problem?

Thank you,

Found what the problem was:

Func_A had another function in itself defined: func_C. Since func_B was a copycat of the func_A with some minor edit, the func_C was called unexpectedly. Renaming func_C into func_D in the func_B fixed the problem.

I have another question about schedule_function. If someone please help?
Is there a way to let the function func_B (scheduled later within one day than func_A) run only if func_A did not return any order at this day?
In other words: how do I skip func_B at this day if conditions of func_A were met at the scheduled time for func_A within this day?

@Igor,

The best way to get help fast is to attach backtest with your problem.

I agree with Vladimir