Sloan,
Try this:
# Rebalance quarterly 1
def initialize(context):
context.counter = 0
schedule_function(rebalance, date_rules.month_end(),time_rules.market_close(minutes = 120))
def rebalance(context, data):
freq_month = 3
context.counter += 1
if context.counter == freq_month:
trade(context, data)
context.counter = 0
def trade(context, data):
for asset in context.assets:
if get_open_orders(asset): return
order_target_percent(asset, context.weights[asset])
Or this:
# Rebalance quarterly 2
def initialize(context):
schedule_function(rebalance, date_rules.month_end(),time_rules.market_close(minutes = 120))
def rebalance(context, data):
this_month = get_datetime('US/Eastern').month
if this_month not in [3, 6, 9, 12]:
log.info("skipping this month")
return
else:
log.info("trading this month")
trade(context, data)