Pending Replace, turned Pending Cancel, turned forever stuck in a long position

While running my Python SDK based algorithm, I ran into an unknown condition that caused one of my limit sell orders to become “stuck” in the “pending replace” condition. My algorithm, seeing it had no true working sell orders, panicked and tried to replace more sell orders.

After accumulating 8 “pending replace” orders, I decided to cancel all orders via the web GUI. Upon doing so, all of the orders were converted from being stuck as “pending replace,” to being stuck as “pending cancel.” I am likewise now stuck in a long position I do not want to be in, with 10 minutes left in the trading day, before a weekend :scream:… I have attached a screenshot of the status of my orders below.

I believe this to be an error with the Alpaca API. I have noticed similar issues have been detected on the paper trading API, but I had not seen an issue of this nature reported for the live trading API, which I am currently using. If anyone has any input as how to rectify this issue, I would be very grateful! I am also willing to help solve this issue, however you think I could be of use.

Update: At 4:03 P.M. the Pending Replace orders disappeared, and my position was successfully liquidated :pray:! Still, if anyone is able to shed some light on this bizarre situation I would be really grateful.

This is a known problem with Alpaca for almost a year and no fix yet.
I have tweeted @AlpacaHQ about this issue. Here is the link to my tweet. Perhaps if many of us in the community reply to that tweet and ask for a fix there, someone at Alpaca support may pick it up.

2 Likes