Insufficient qty available for order

  1. I am currently using the REST call to make an order, and then monitoring the stream to see if an order is fulfilled. When I get the order stream event “filled” I place a limit order, but this has to wait several seconds. If I do it immediately, it fails with "insufficient qty available for order (requested: 500, available: 0) " despite the filled event having a position_qty of 500. If I wait for several seconds, it works fine. How long should I wait? I’d like to get the lag as low as possible.

  2. speaking of quantity, it seems like the position quantity is reserved on a per order basis. after a fill, I want to create a limit order on my target price, a stop order on my exit price,and a market close order to get out of the position. I should have plenty of time to cancel the 2 orders out of the 3 that does not execute. But I can’t create the last two orders, getting the same insufficient qty error as the above. Is there a way to do this?

thanks
Jeff