Frequently, I need to update an initial order multiple times, mostly to catch up with a fast moving market. For the life of me I could not figure out how exactly the update mechanism works in Alpaca. It seems convoluted!
(In another API you would simply send a new limit price with existing order_id and that would be that)
Here are the steps I moved through. Could anyone please fill the rest in the rest?
api.submit_order(), returns Order object with “order_id_1”, “client_order_id_1”, status ACCEPTED
channel trade_updates receives order dictionary with “order_id_1”, “client_order_id_1”, status NEW
– time passes suppose the order does not fill or cancel
api.replace_order(“order_id_1”, new_price) returns “order_id_2”, “client_order_id_2”, status ACCEPTED ?
channel trade_updates receives order dictionary with “order_id_2”, “client_order_id_2”, status REPLACED
price moves fast, no fill, I want to update the order again
- api.replace_order(“order_id_2”, new_price) returns error “… order in replaced status cannot be changed…”