Very Slow Market Sales in Paper Trader (C#)

I need to liquidate open positions and was experiencing non-stop timeouts (over an hour) when calling DeleteAllPositionsAsync(). I then wrote a small method to retrieve all positions and delete each one individually when I noticed that the call to post a market order is averaging 10 seconds (I also tried delete position which resulted in the same duration) with some calls timing out (perhaps because of the prior calls to delete all of the positions).

I’m also having an issue with deleting a simple limit order to no avail. Even after letting an hour pass.

Is there a problem with the server on the paper side causing this? It makes me quite nervous to do live trading.

Don’t forget about the REST API requests rate limit - only 200 requests per minute for single user/IP are allowed. The single bulk positions closing call should work faster than several independent calls. The .NET SDK handles the HTTP 429 status code and retries call after the random delay. It’s not an ideal solution but it works in most cases. Your responsibility as an SDK/API consumer is to reduce the number of API calls as much as possible for preventing timeouts/retries.

But maybe it’s just a server-side issue related to your account. I’ve never experienced such long delays during SDK testing.

I don’t typically experience this. Remember, I’ve resorted to selling individual market sales because the bulk method was timing out (for at least half of an hour of repeated attempts) and I can’t even make 200 calls in half an hour right now, let alone a minute. I haven’t come close to exceeding the request limit and haven’t received the rate limit exception.

This continues to be a problem and we’ve reset the account on multiple occasions. I’ve noticed it is also creating short orders (this may be due to multiple attempts to close out the account).

Have you tested this with 1000 - 1500 positions?

No, I’ve never tested it for such a big portfolio (1000-1500) positions. But in any case, the DeleteAllPositionsAsync() method makes only 1 HTTP request, and all real position liquidation logic runs on the server-side. If you have too many open positions it can take time and most probably timeout will be triggered on the caller side (in the SDK code). Most of the REST calls expect a fast turnaround and it’s the reason why SDK never changes the default HTTP client timeout. But looks like in some rare cases users should be able to configure timeout values.
I’ll add the timeout parameter for this call in the next SDK release. If you have a better idea of how to prevent it on the client side - just tell me.

Hey Oleg, it’s difficult to think of a better idea unless I know how the server is liquidating the shares. Exposing the trading client’s timeout should help, thank you.

This new property is available in the latest 5.1.1 release.