Hello there:
I was reding Ibridgepy documentation, and I saw there is a method called "schedule function", this method allows me to define a particular function to be executed after a particular schedule…
Now I was wondering, how can I write my code so that it only executes a function in a certain period of time, let's say from 9:30 to 10:00 (the most volatile half hour of the trading day)…
I would definitely use the schedule function to put the lower limit on time… but what about the upper limit??? that is… How can I write a code that only executes before a particular hour using ibridgepy??
Thanks
Hello Ghery,
You can use 'time_rules.spot_time' of the schedule function to achieve this.
Let's say you want to trade only between 9:30 am to 10:00 am and want to check the entry conditions every 10min.
you can create four schedule functions as below and achieve your objective.
schedule_function(func=strategy, date_rule=date_rules.every_day(), time_rule=time_rules.spot_time(hour=9, minute=30, second=0))
schedule_function(func=strategy, date_rule=date_rules.every_day(), time_rule=time_rules.spot_time(hour=9, minute=40, second=0))
schedule_function(func=strategy, date_rule=date_rules.every_day(), time_rule=time_rules.spot_time(hour=9, minute=50, second=0))
schedule_function(func=strategy, date_rule=date_rules.every_day(), time_rule=time_rules.spot_time(hour=10, minute=00, second=0))
Hope this helps!