Limit sell order fails with insufficient quantity even when the quantity is correct

Here is the log from my program:

Latest position symbol NAIL filled orders.
8/3/2020 7:29:46 PM: 75f2b966-f3c9-4f5d-8b40-36f6a78ed20f: FilledAtUtc: 8/3/2020 7:19:12 PM, FilledAt: 43.31 (Filled Market 23 Buy)
NAIL: AverageEntryPrice: $43.31, UnrealizedProfitLossPercent: -0.2770722696836758, Quantity: 23
Attempting to place limit sell order for NAIL for quantity: 23 at price 43.19 (Place time: 8/3/2020 7:29:46 PM).
Exception: Alpaca.Markets.RestClientErrorException: insufficient qty available for order (requested: 23, available: 0)

As can be seen above, the buy order was filled successfully at 8/3/2020 7:19:12 PM (UTC) for a quantity of 23. The _tradingClient.GetPositionAsync(symbol) API call correctly reports the quantity as 23. However when the limit order is placed at 8/3/2020 7:29:46 PM (UTC) for the same quantity, the API reports that the available quantity is 0.

What is going on?

1 Like

Hi,
I’ve seen this happen when you have another opened order for the same amount on the same position (e.g you used a bracket order, and then tried to close the position manually without cancelling the stop_loos / take_profit orders)

make sure you don’t have any other orders, and then try close your position.