I am backtesing at minute level and I can see that when I buy or sell a security the price used to update my portfolio is the closing price of the next minute bar. Shouldn't it be used the closing price of current handle_event bar?
--------Example--------
In my algorithm I set the following in initialize:
set_commission(commission.PerTrade(cost=0.00))
set_slippage(slippage.VolumeShareSlippage(volume_limit=0.25, price_impact=0.0))
When I backtest I can see that every time I take long or short positions on "AAPL", the price used to update context.portfolio.cash is the close price of next handle_data:
---handle_data---
portfolio 100000.000000 cash 100000.000000 positions 0.000000 returns 0.000000
"AAPL" open 47.079513 close 47.155229 volume 1354710
Taking shot position "AAPL" (num -100): order_target(symbol('AAPL'), -100)
---handle_data---
portfolio 100000.000000 cash 104709.951340 positions -4709.951340 returns 0.000000
"AAPL" open 47.150943 close 47.099513 volume 498474
---handle_data---
portfolio 99999.285700 cash 104709.951340 positions -4710.665640 returns -0.000007
"AAPL" open 47.099656 close 47.106656 volume 490886
Take long position "AAPL" (num 100): order_target(symbol('AAPL'), +100)
---handle_data---
portfolio 99988.428340 cash 95266.905340 positions 4721.523000 returns -0.000116
"AAPL" open 47.106656 close 47.215230 volume 372385