Is there a good way to do a sell all stocks at market close using order_optimal_portfolio?
I can use a hack like this, ,but looking for something cleaner:
def initialize(context):
...
schedule_function(sell_all, date_rules.every_day(), time_rules.market_close(minutes=1))
def sell_all(context,data):
order_optimal_portfolio(
objective=opt.TargetWeights({sid(8554): 0.0}) ,
constraints=[],
)