Order Execution times

I am pasting information which I received from Dan as part of Req#215078, since I believe it will be beneficial to all:

Timings of order execution:

00:00.000 your algo requests an order
00:00.010 Alpaca receives the request (assumes 1/2 of total round trip request time of 20ms)
00:00.011 Alpaca creates order and sends request to execution partner
00:00.012 Alpaca sends order number and status code back to algo
00:00.020 Order is executed (median 9ms)
00:00.021 Alpaca receives order status from execution partner
00:00.022 your algo receives the order number and 200 status (assumes 1/2 of total round trip request time of 20ms)
00:00.045 Alpaca updates internal db of orders with 'filled' status (typically 25ms from fill time)

Status of orders in database:

While orders may fill very quickly, the status can take awhile to update. If you are using the get_order_by_id to check status the update time is typically about 25ms. However, if you are using the get_all_orders endpoint or the trade_update_stream to check status the update time can be considerably longer in the range 150-250ms. The order can be filled but you don’t know it. Trying to cancel it will result in an error.

Advice for cancellation:

Unless there is an overarching reason not to, perhaps consider canceling orders after 1 second. If you will simply be ordering the same thing but at a different limit price you should use replace rather than cancel (it only takes one step and not two).