Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
annually rebalance

hi guys,

I need to set up a portfolio with a rebalance once a year, can someone help me? thanks

2 responses

@ marco

Hope this will help:

# Rebalance Yearly  
# ----------------------------------------------------  
assets, wt, lev = symbols('QQQ', 'TLT'), [.5, .5], 1.0  
# ----------------------------------------------------  
def initialize(context):  
    schedule_function(trade, date_rules.month_start(), time_rules.market_open(minutes = 65))  
def trade(context, data):  
    if get_datetime().month not in [1] or get_open_orders(): return  
    for i, asset in enumerate (assets):  
        if data.can_trade(asset):  
            order_target_percent(asset, lev*wt[i])  

great job @ Vladimir
thanks