Hi,
I’m trying to submit multiple orders in parallel. I’ve tried couple of methods and doesn’t seem that orders can be submitted simultaneously.
I tried to test with submitting 2 orders, with:
- submit first order, then the next. This is just for comparison, to see the latency for submitting an order. There is a ~0.1s delay between the two orders submission, which means the first order takes 0.1s to be submitted before the second one start to submit.
- using asyncio to submit 2 orders. It’s still the second order was submitted ~0.1s after the first one submitted.
- created 2 threads with threading module to submit 2 orders. The behavior is the same as above, still 0.1s different between the two order submission.
- using multiprocessing. This returns an SSL error from multiprocessing, as the two processes are using the same Alpaca api connection.
I understand that Python async and threading are not truely parallelism, so it might be one of the reasons that two orders not being submitted simultaneously. But I wonder if there is any kind of limit from Alpaca API that prevent this? Say, if hypothetically there is a way that 2 orders come in exactly at the same time, will the REST API take the 2 orders simultaneously? Will it solve the problem if I switch to Golang which handles parallelism better?
Thanks!