I want to create multiple orders for multiple users asynchronously in binance api using python. I know how to a create a single order for a pair of api key and api secret.
from binance.client import Client as BinanceClient
from binance.enums import *
binance_api_key = 'api_key'
binance_api_secret = 'api_secret'
binance_client = BinanceClient(binance_api_key, binance_api_secret)
single_order = client.create_test_order(
symbol='BTCUSDT',
side=SIDE_SELL,
type=ORDER_TYPE_LIMIT,
timeInForce=TIME_IN_FORCE_GTC,
quantity=1,
price='16000'
)
I can just copy this or use a for
loop to repeat the process. But the problem is that this code does not create orders asynchronously. That is, it starts from the first api key and api secret and then execute the second and third one. This will create the orders one after another and I loose time because each trade takes approximately 0.5 seconds.
I have tried this answer but honestly I couldn't figure out how to use it to solve my problem.