I'm not sure what Quantopian is doing with their Q fund broker, but back in the day when retail trading was supported, my understanding is that orders were sent to the broker as they were encountered in the code, but price & volume data and portfolio state were updated on the whole minute. So, the flow was:
Get OHLCV bar and broker data ---> Determine new portfolio ---> Submit set of orders ---> Wait for new OHLCV bar and broker data
If you don't wait for the result of the first set of orders, and submit additional orders, then bad things can happen.
@ Jamie - are there some guards for this problem when using this code:
objective = opt.TargetWeights(weights)
constraints = []
order_optimal_portfolio(
objective=objective,
constraints=constraints,
)
How does order_optimal_portfolio
manage multiple calls within a trading minute? Or would it behave the same as order_target_percent
?