node-binance-api icon indicating copy to clipboard operation
node-binance-api copied to clipboard

Market Buy using Total instead of Amount (or Quantity)

Open shifatul-i opened this issue 3 years ago • 9 comments

As the title mentions, how do I place a buy order using the Total Instead of mentioning the Quantity. Please see screenshot below for reference.

The documentation does not have an example of this type of order.

Screenshot_20210101-085528_Binance

shifatul-i avatar Jan 01 '21 17:01 shifatul-i

Hello, This is done by the parameter quoteOrderQty of the endpoint POST /api/v3/order (see documentation here : https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade).

But looks like this is not implemented yet (see node-binance-api.js:366).

edafonseca avatar Jan 02 '21 09:01 edafonseca

Hello, This is done by the parameter quoteOrderQty of the endpoint POST /api/v3/order (see documentation here : https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade).

But looks like this is not implemented yet (see node-binance-api.js:366).

Yes, I saw that. ended up using this library: https://github.com/Ashlar/binance-api-node

image

shifatul-i avatar Jan 02 '21 10:01 shifatul-i

Hello, This is done by the parameter quoteOrderQty of the endpoint POST /api/v3/order (see documentation here : https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-order--trade).

But looks like this is not implemented yet (see node-binance-api.js:366).

@jaggedsoft will this be implemented soon?

cheezeburger avatar Feb 01 '21 14:02 cheezeburger

@cheezeburger Add this in the order function.

if (opt.type == 'MARKET' && typeof flags.quoteOrderQty !== 'undefined') {
            opt.quoteOrderQty = flags.quoteOrderQty
            delete opt.quantity;
} 

shivchawla avatar Feb 16 '21 18:02 shivchawla

quoteOrderQty didn't implemented to Futures APi on Binance side, so we have to wait to implement on them.

PS: https://dev.binance.vision/t/is-there-a-plan-to-introduce-quoteorderqty-option-in-margin-and-futures-market-orders/742/7

ne0c0de avatar Mar 16 '21 15:03 ne0c0de

How do I structure the query for a market buy using quoteorderQty? Ive tried every combination I can think of but keep getting "{"code":-1104,"msg":"Not all sent parameters were read; errors

Lippa73 avatar Dec 13 '21 23:12 Lippa73

unfortunately it's still not implemented on Binance API yet

ne0c0de avatar Dec 13 '21 23:12 ne0c0de

I thought the snippet shown by shivchawla above, and has been added to my code resolved it?

EDIT: I managed to solve it, in case anyone else is looking for it, this is the required syntax -

binance.marketBuy("BTCUSDT", quantity, {type:'MARKET', quoteOrderQty: amount}, function(error, response) { console.info("Market Buy response", response); console.info("order id: " + response.orderId); });

quantity needs to be input, however it is ignored by the query

Lippa73 avatar Dec 13 '21 23:12 Lippa73

@Lippa73 Its giving me undefined response. Are you sure its working for node-binance-api ?

Mas313 avatar Jun 25 '23 06:06 Mas313