Today we are releasing a brand new method called schedule_function that allows you to specify on what days and at what times you want a function to run. Instead of manually calculating the day and time in your algorithm, you can pass it in this function automatically! It will execute your code based on the rules you pass - on a daily, weekly or monthly schedule, or at a specific time during the trading day.
This means, you can easily schedule a piece of code to run once a day, at the beginning of a month, or only execute orders 15 minutes before the market closes - to name a few examples.
Take a look at the example below which shows a portfolio rebalance that happens the first trading day of the month, 30 minutes after the market opens or read more about how schedule_function works. Try it out with your algorithm and we'd love to hear your feedback!