binance-exchange/node-binance-api

Unclear response when use buy/sell methods

dubrovsky-kiril opened this issue · 8 comments

Hello. Thank you for library! I got small question regarding buy/sell api. So far I get unclear response. Do you know what might be the reason of it? :)

Here is the code:
BINANCE.buy("IOTAETH", 5, 0.00225758, {type:'LIMIT'}, (error, response) => {
console.log('Error:', error)
console.log("Limit Buy response:", response);
console.log("order id: " + response.orderId);
});

Here is the response:
Error: null
Limit Buy response: {}
order id: undefined

Binance will send a {} response to order requests when you have the options.test flag set to true:

binance.options({
    // ...
    test: true // If you want to use sandbox mode where orders are simulated
});

This is by their design. It's use is more to get an idea for how long it will take for the exchange to receive and process your order, but not go as far as the final step of putting into their matching engine. So if you're simulating trading, it's up to you to track what you believe your sale/buy prices and quantities were, ie. using the order book.

Ok, thank you! Got it! With no test env trade get processed.

@Keith1024 but buy/sell methods will only place my order in order book right? Or should it also respond me with order execution process?

Test mode is very confusing, its' best to not use it at all.
All it does is return a blank response and not send the order to their matching engine. So it won't show anywhere. Kind of pointless if you ask me.
I will be developing a paper testing module we can plug in to the API in order to help you test your strategy.
It's a ways out though

@jaggedsoft Ok, thanks for your response. But in case I am not using test mod. Then buy/sell methods only place my order in orderbook right? They do not inform me about this order execution updates? For this purpose I need to use statusUpdate method, right?

If you're using test mode, the buy and sell orders do nothing.
They will not post anywhere.

Ok, but what about case when I am not using test mod and using real one?

It should show in your orderbook yes, and it should also show under the websocket execution update
see execution_update()
https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md#user-data-account-balance-updates-trade-updates-new-orders-filled-orders-cancelled-orders-via-websocket