jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.57k stars 767 forks source link

Market Buy using Total instead of Amount (or Quantity) #552

Open shifatul-i opened 3 years ago

shifatul-i commented 3 years ago

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

edafonseca commented 3 years ago

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).

shifatul-i commented 3 years ago

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

cheezeburger commented 3 years ago

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?

shivchawla commented 3 years ago

@cheezeburger Add this in the order function.

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

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

Lippa73 commented 2 years ago

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

ne0c0de commented 2 years ago

unfortunately it's still not implemented on Binance API yet

Lippa73 commented 2 years ago

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

Mas313 commented 1 year ago

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