Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Semi-monthly rebalancing

Hi,

Is it possible to implement semi-monthly rebalancing using schedule_function?

Regards,
Ed

3 responses

Probably something like this:

    schedule_function(func=HandleDataRebalance, date_rule=date_rules.month_start(days_offset=0))  
    schedule_function(func=HandleDataRebalance, date_rule=date_rules.month_start(days_offset=15))  

Thank you!
days_offset=10 works for me:

def initialize(context):  
    schedule_function(func=rebalance, date_rule=date_rules.month_start(days_offset=0))  
    schedule_function(func=rebalance, date_rule=date_rules.month_start(days_offset=10)) 

def rebalance(context, data):  
    print data[symbol('SPY')].price

def handle_data(context, data):  
    pass  

2014-01-02 PRINT182.95
2014-01-16 PRINT184.4
2014-02-03 PRINT174.17
2014-02-18 PRINT184.2401
2014-03-03 PRINT184.93
2014-03-17 PRINT186.34
2014-04-01 PRINT188.25
2014-04-15 PRINT184.23
2014-05-01 PRINT188.32
2014-05-15 PRINT187.39
2014-06-02 PRINT192.9
2014-06-16 PRINT194.3
2014-07-01 PRINT197.06
2014-07-16 PRINT197.97
2014-08-01 PRINT192.49
2014-08-15 PRINT195.73
2014-09-02 PRINT200.59
2014-09-16 PRINT200.49
2014-10-01 PRINT194.34
2014-10-15 PRINT186.29
2014-11-03 PRINT201.75
2014-11-17 PRINT204.38
2014-12-01 PRINT205.8
2014-12-15 PRINT199.48

Ed

Good experiment. Revealing to see that days offset are not calendar days -- but market days. Had I thought about it I probably would have surmised that. But to see it in your results is elucidating.