Pegged NBBO/MidPoint orders, each exchange has algo check documentation or contact them about time/price/Fifo and most importantly pro-rata allocations for peggged orders.
Here is a doc from NYSE to have a look at: https://www.nyse.com/publicdocs/nyse/markets/nyse/Pillar_Differences.pdf
Best i could find was:
((BP1 x N1) + (CP * N2)) / (N1+ N2) = AVG
BP1 = initlal price paid
N1 = intial shares bought
CP = current price
AVG is your desired average cost
Put the numbers in and solve for N2
A lot of the literature relies on estimating impacts of large orders (n), typically from major funds, that are split into child orders and executed over some period. Usually this data is proprietary and difficult to replicate. The metaorders used in this paper https://arxiv.org/pdf/1412.2152.pdf are one example (see footnote 3). This paper explains their ...
Generally in a regulated exchange, you are not allowed to skip price points. In the case you have shown, BOB's new Buy order will skip the price point at 503 and execute at $504. Therefore the order will get cancelled/expired/rejected even if the time constraint of the order is not IOC/FAK.
So in both scenarios you mentioned (whether the order quantity is 20,...