I am testing my order process via paper trading account. I am relying on the web socket connection to be my source of truth for order state. However, when I delete an order that is in an “accepted” state it doesn’t send an event via the web socket. Any ideas why?
@tuck You asked “when I delete an order that is in an “accepted” state it doesn’t send an event via the web socket. Any ideas why?”
Technically, what’s going on in the background for order events is Alpaca forwards events which are received from the execution venue. These are typically new (the venue sends this message to confirm they got the order) or filled (the venue sends this when filled) or cancelled (the venue sends this when they cancel an order). However, when an order is in an accepted state it hasn’t been sent to the venue yet. Therefore, if the order is deleted, the venue doesn’t send an event and Alpaca doesn’t forward an event.
If the order is in a new state then the venue has received it. So, if the order is deleted, the venue will respond with a cancelled event which is then forwarded to the event stream.
Just a little nuance in how the event stream is generated. It’s only events received from the execution venue. There is a description of the order flow, and associated states, here in the docs.
Thank you for such a quick response. I was assuming this is the case since the “accepted” status has another nuance of not being able to be modified. You would have to delete. This is only an issue because I am testing my order process outside of market hours but I can add the business logic to handle accordingly.
I am very tempted to create a test application to simulate Alpaca responses so I can test outside of market hours. The rest api is easy enough but the web socket simulation would be the difficult piece. Along with me learning these nuances.
Thanks again and have a great rest of your day.