Market on Close Logic
Check LogicThe order must be placed at least 5 minutes (factoring in transmission latency) before the close for it to be accepted. (Up to October 29th 2018 the ofsett was 10 minutes before the close)
Fill LogicThe order is filled on NASDAQ on the closing print (aka 6 print) at the closing price. The number of shares filled is the symbol's ask_size * lot_size (for buying) or bid_size * lot_size (for selling). If the order is partially filled, the remainder will be cancelled at the end of the simulation since there is at most one closing print for each symbol. This fill takes liquidity.
Cancel LogicThe order must be cancelled at least 10 minutes before market close (factoring in transmission latency).