This snippet of code rebalances every other wednesday. How can it be modified so I can easily select the number of weeks between rebalances? I want to test every week, every 3 weeks, 4 weeks...
context.rebalance_day = False
if get_datetime().weekday() == 2: # current day is Wednesday (Tue = 1, Wed = 2, ...Mon = 7)
if context.skip:
# Today is a Wednesday to skip, reset the variable keeping track of this
context.skip = False
return
else:
# Today is a Wednesday to rebalance, reset variable for next Wednesday
context.skip = True
else:
# Today is not a Wednesday
return
# Run daily pipeline screen
context.rebalance_day = True