Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Momentum Rotation issue with repetition period

Two problems I am having with modding this one:
1) (Verify please) How does one change this to only buy the top two etf's based on three month return and that etf is also above 100 SMA? I believe that is already being done, but please correct me if I'm wrong.
2) The thing I definitely can't figure out is how to change the monthly repetition to every two weeks. My attempts are failing miserably.
This gives me errors: date_rules.day_start(days_offset=15)
--AttributeError: 'DateRuleFactory' object has no attribute 'day_start'--
When I use: date_rules.week_start(days_offset=2), it appears in the logs to use one week no matter what value I place in offset.
Any help would be appreciated.

1 response

It appears that in the wee hours of the morning, I got the two week period thing to work. The docs are really not concise, but finally in there it states:
To schedule a function more frequently, you can use multiple schedule_function calls. For instance, you can schedule a function to run every 30 minutes, every three days, or at the beginning of the day and the middle of the day.
So doing two schedule_functions in a row got it to work as expected.
ex:
schedule_function(func=rebalance, date_rule=date_rules.month_start(),time_rule=time_rules.market_close(hours=0, minutes=15))
#this one changed:
schedule_function(func=rebalance, date_rule=date_rules.month_end(days_offset=9),time_rule=time_rules.market_close(hours=0, minutes=15))