locked-property of endpoint "account"

I have one question according to the endpoint GET /api/v3/account

It returns something like this:

{
  ..
  "accountType": "SPOT",
  "balances": [
    {
      "asset": "BTC",
      "free": "4723846.89208129",
      "locked": "0.00000000"
    },
    {
      "asset": "LTC",
      "free": "4763368.68006011",
      "locked": "0.00000000"
    }
  ]
}

What does the “locked”-property mean? Does it only consider the active (unfilled) orders which reserves the money until the order is filled?

Yes, locked is the sum of all active orders (unfilled parts of the total order volumes).

Continuing the topic - how to unlock locked assets? What command will cancel active order(s)?

To unlock these “locked” assets, you need to cancel the active orders that are reserving these funds. You can do this using the DELETE /api/v3/order endpoint, which allows you to send a request to cancel an order on Binance. Here’s a brief overview of how to perform this:

  1. Identify the Order: You need the orderId, symbol, and other optional parameters like origClientOrderId (if you set it during order creation) to specify which order to cancel.
  2. Send a Cancel Request: Use the DELETE /api/v3/order endpoint with the necessary parameters to request cancellation.
  3. Check the Response: The response from the API will confirm whether the order was successfully canceled. After cancellation, the funds that were “locked” in this order will be released back into your “free” balance.

Basic example for cancel request order…

from binance.client import Client

api_key = ‘your_api_key’
api_secret = ‘your_api_secret’
client = Client(api_key, api_secret)

Example to cancel an order

order_id = ‘123456’ # This should be the actual order ID
symbol = ‘BTCUSDT’ # Symbol of the order

result = client.cancel_order(symbol=symbol, orderId=order_id)
print(result)

This script will send a request to Binance to cancel the specified order, thereby unlocking any assets that were held in it.

Thanks a lot for the answer!