** Creating multiple commands for multiple ASE API

As a developer, connecting in multiplication for different pairs outside the APIs asynchronous is crucial whishing with a large volume of transactions or whip implementation of complement trading strategies. In this article, we walk that you manage the multiplier processing bodies for asynchronous multiplier APIs on Binance Python Python.

Premises:

  • You have an API Binance key and a secret pair.

  • You have been installed the Binance library by PIP:PIP Instal Binary Customer

Step 1: Create an order with multiple pairs

To create orders multiplied for different pairs on the API keys, to the west for the unique orders of the necessary pairs. We will use "binance.client.order.

Python

Client Binance.Client Import

Set -vis Api Binance key and the secret pair

api_key = "your_api_key"

api_secret = "your_pi_secret"

Creates

Customer = Customer (API_KY, API_SECRET)

Define the pairs for which the welfare commands

pairs = ["Goddt", "bnbusdt"]

Republic

commands = []

for pair in pairs:

Set the type and parameters set

params = {

"Lateral": "market",

"Type": "limit"

}

Create a newer order for the currrin

command = clinic

symbol = pair,

Side = Params ['Late'],

Type = Params ['Type'],

Quantity = 100,

set to trade to 100 units

Timeinforce = 'GTC',

Set Time-in-Force to "Good to Cancel"

comment = f "order for {pair}"

)

Add command items

commands.apppend (order)

Print

For i, order in enumeration (orders):

print (f "order {i+1}: {command.symbol} - quantity: {order.quantity}")

Re

Step 2: Create multiple commands for each pair asynchronous **

To create multiplied commands for each pair asyncron we will dose alopo to leave an order. This approach can be intensive in memory and it may not be suitable for the numbers of stoppage larvae.

Python

Time time imports sleep

Define the API key and the secret pair

api_key = "your_api_key"

api_secret = "your_pi_secret"

Creates

Customer = Customer (API_KY, API_SECRET)

Define the pairs for which the welfare commands

pairs = ["Goddt", "bnbusdt"]

Republic

commands = []

for pair in pairs:

Set the type and parameters set

params = {

"Lateral": "market",

"Type": "limit"

}

Create a newer order for the currrin

command = clinic

symbol = pair,

Side = Params ['Late'],

Type = Params ['Type'],

Quantity = 100,

set to trade to 100 units

Timeinforce = 'GTC',

Set Time-in-Force to "Good to Cancel"

comment = f "order for {pair}"

)

Add command items

commands.apppend (order)

Wait for a short time before crying another order

Sleep (1)

Print

For i, order in enumeration (orders):

print (f "order {i+1}: {command.symbol} - quantity: {order.quantity}")

Re

Step 3: Cancel the orders

Asynchronous cancellation orders, you can make theclient.order.Cancelmethod. This approach is more efficiently multiplied requests.

` Python

Define command IDs

order_ids = [str (order.id) for orders in commands]

Cancel the orders

For order_id in orderon_ids:

Customer.order.

Fiat Fiat Market

Leave A Comment

Cart

No products in the cart.