binance-exchange / binacpp

Binance C++ library
MIT License
212 stars 108 forks source link

Cannot make market trades #32

Open joshua-cooper opened 6 years ago

joshua-cooper commented 6 years ago

I get an error when I try to make a market trade using the example,

long recvWindow = 10000;
Json::Value result;
BinaCPP::send_order( "BNBETH", "BUY", "MARKET", "GTC", 20 , 0,   "",0,0, recvWindow, result );

The output of result is:

"code" : -1106,
"msg" : "Parameter 'timeInForce' sent when not required."

I have tried to change the timeInForce to each available one but it doesn't work. If I remove it completely, I get this error:

"code" : -1105,
"msg" : "Parameter 'timeInForce' was was empty."

I have managed to make limit orders but have yet been able to make a market order. Any idea what is wrong?

As a side note, is it possible to make orders using 100% of the available asset?

AlconDivino commented 6 years ago

i don't know this error, but when sending a market order i get error -1021: Timestamp for this request is outside of the revWindow

Any idea?

AlconDivino commented 6 years ago

In binacpp.cpp i copied the send_order() function and called it send_order_market().

i commented out the time in force code:

post_data.append("&timeinforce="); post_data.append(timeinforce);

did the same for price .

Worked out for me