Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Schedule function month_start days offset limit Question

Salutations from South Africa :)

Hope you are all well.

I have a quick question with regards to the schedule function, particularly the month_start property. I am aware that the days offset for month_start is limited to 20 or so days. So if i wanted to run a function let's say once every 3 months, how would I achieve this?

Thank you in advance...

2 responses

You can create a global variable in the initialize function
context.run_function = 0

Then in the function that you are scheduling you can add an initial condition at the beginning of the code.
If context.run_function % 3 == 0:
---function code---
context.run_function +=1 (Note that advancing the variable by one needs to be outside the if statement, so that it advances by one every time the function is called)

The function gets called every month, but will only run the code when context.run_function is divisible by 3 with no remainder (every 3rd month).

Hope that helps.

Wow thank you so much, Cory.
This will be a big help.
Totally makes sense.

All the best to you.