How to calculate how much i can buy

Hi

From the API I the the asset in my wallet. Let’s say that I have this: 1 ETH, 100 EUR, 1000 COMBO

Now let’s say that I want to place an market order for BTC.

let’s say I want to pay with COMBO, how do I calculate how many BTC I can buy and how do I tell the newOrder endpoint that I will pay with my COMBO’s ?

Also:

how do I create a limit/take_profit sell order when the price is xxx and specify that I want to get e.g EUR back when the order is executed ?

You would do that by using appropriate symbol for the trading pair: COMBOBTC or BTCCOMBO.

However, at the moment Binance does not offer this trading pair. You cannot buy or sell BTC for COMBO directly. You will have to go through an intermediate, for example: sell COMBO for USDT (using symbol=COMBOUSDT), buy BTC with USDT (symbol=BTCUSDT).

symbol=BTCEUR is available though. Use that to buy or sell BTC for EUR.

In general, you need to look at the order book. For example:

curl 'https://api.binance.com/api/v3/depth?symbol=BTCEUR&limit=10'
Response
{
  "lastUpdateId": 7212812426,
  "bids": [
    [
      "52300.27000000",
      "0.00345000"
    ],
    [
      "52300.26000000",
      "0.00433000"
    ],
    [
      "52294.76000000",
      "0.01435000"
    ],
    [
      "52294.75000000",
      "0.02361000"
    ],
    [
      "52294.23000000",
      "0.00015000"
    ],
    [
      "52292.28000000",
      "0.01039000"
    ],
    [
      "52290.30000000",
      "0.03697000"
    ],
    [
      "52290.29000000",
      "0.02000000"
    ],
    [
      "52290.07000000",
      "0.06411000"
    ],
    [
      "52288.98000000",
      "0.03909000"
    ]
  ],
  "asks": [
    [
      "52302.05000000",
      "0.02000000"
    ],
    [
      "52302.06000000",
      "0.02361000"
    ],
    [
      "52302.24000000",
      "0.00021000"
    ],
    [
      "52303.33000000",
      "0.00172000"
    ],
    [
      "52304.07000000",
      "0.02297000"
    ],
    [
      "52304.11000000",
      "0.03824000"
    ],
    [
      "52305.23000000",
      "0.01300000"
    ],
    [
      "52305.68000000",
      "0.01300000"
    ],
    [
      "52307.80000000",
      "0.01204000"
    ],
    [
      "52308.76000000",
      "0.00015000"
    ]
  ]
}

See asks for offers to sell BTC for EUR. With the order book in that state, the best price is 52302.05 EUR for 1 BTC, so with 100 EUR you will be able to buy 0.00191 BTC (considering the minimum lot size 0.00001). If the offered quantity is less than what you need, you’d get the next best price, and so on.

For type=MARKET orders you can use quoteOrderQty parameter: for example quoteOrderQty=100 to buy as much BTC as possible at the current market price spending no more than 100 EUR.

Thanks a lot for the details.

If I understand it correctly, then the symbol is the crypto to buy/sell and then the ‘currency’ to buy with

e.g BTCEUR, ETHEUR etc.

Is there a way to get all symbols?

Answered in How can I get possible symbols