hi guys,
I need to set up a portfolio with a rebalance once a year, can someone help me? thanks
hi guys,
I need to set up a portfolio with a rebalance once a year, can someone help me? thanks
@ 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])