sp
sp
I'll have to dissect the code and see what is happening, and I'll get back to you. but for now, it seems you can export your code to some other function, say "run_once" and add
schedule_function(run_once, date_rules.every_day(), time_rules.market_close(minutes = 5))
to initialize instead of time and logic checking.