Is it possible to use the intraday pipeline to determine my trades 17 minutes before the close, then execute using Market On Close (MOC) orders? Thank you!
Is it possible to use the intraday pipeline to determine my trades 17 minutes before the close, then execute using Market On Close (MOC) orders? Thank you!
I can determine the trades 17 minutes before close by using:
schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_close(minutes=17))
Just not sure how to then execute the trades as MOC.
Quantopian doesn't support an order type of 'Market On Close'. Some brokers provide this order type but Quantopian doesn't and it can't be simulated.
The underlying issue is purely logical. The 'close' price is the price as of the last trade of the day. One can't know that price until the last trade. However (and here's the rub) if it's the last trade then one cannot fill any orders after that (ie the markets are closed).
As a workaround, one could get close by entering trades 1 minute before market close and therefore get the prices as of that time. There are a few 'gotches' with this approach but if that would be acceptable, I could include an example.
This may disappoint you but Quantopian phased out live trading last year (see https://www.quantopian.com/posts/phasing-out-brokerage-integrations ).
There are some non-Quantopian options available. Search through the forums here. Here's an exxample https://www.quantopian.com/posts/quantopian-is-ending-broker-integration-and-live-trading.