Below is my initialize definition:
def initialize(context):
set_slippage(slippage.FixedSlippage(spread=0.00))
set_commission(commission.PerShare(cost=0.001, min_trade_cost=0))
# parameters
# --------------------------
context.n_stocks = 1000 # universe size, top market cap
context.N = 4 # trailing window size, days
# --------------------------
schedule_function(
do_portfolio_construction,
date_rule=algo.date_rules.every_day(),
time_rule=algo.time_rules.market_open(minutes=1),
half_days=False,
)
schedule_function(
close_all,
date_rule=date_rules.every_day(),
time_rule=time_rules.market_close(minutes=5)
)
attach_pipeline(make_pipeline(context), 'my_pipe')
context.output = pd.DataFrame()
Basically I place my long/short orders at 9:31am and close all open positions 5 minutes beforeclosing time, therefore I should not have any overnight postions unless there are some stocks /orders not filled by end of day. In research platform, my algo works properly but in contest backtest, it doesn't! It seem to be placing orders every minute. Does this have something to do with the auto detection of estimate_intraday and is my setup considered intraday? How do I rectify this?