Python SDK: How to send/ cancel orders in a non-blocking way


Using the Python SDK, the standard way to send an order is using the following command:

limit_order = trading_client.submit_order(order_data=limit_order_data)

However, this command seems to block the python script execution until a response is returned from the Alpaca server (which takes a few hundred ms based on my tests).

Is there any way to send an order request and not wait for the server reponse before proceeding with the rest of the script? The response should then be received via an async callback.

Same question for get_order_by_id and cancel_order_by_id

Thanks for your help.

In case anyone is interested, It is possible to accomplish it by either using multiple threads (Threading module), or using asynchronous python (asyncio module) and calling the place order function in parallel tasks.