I'm trying to set my re-balance function so it will be triggered once every year and am getting errors.
I've read other posts in the forum about this and haven't managed to get it to work.
Any help could be much appreciated, see code:
def initialize(context):
algo.attach_pipeline(risk_loading_pipeline(), 'risk_factors')
# Schedule our rebalance function
algo.schedule_function(func=rebalance,
date_rule=stock_selection_by_calendar(),
time_rule=algo.time_rules.market_open(hours=0, minutes=30),
half_days=True)
# Record our portfolio variables at the end of day
algo.schedule_function(func=record_vars,
date_rule=algo.date_rules.every_day(),
time_rule=algo.time_rules.market_close(),
half_days=True)
def stock_selection_by_calendar(context,data):
today = get_datetime()
return today.month == 1 and today.day == 1