Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

market orders aren't working #2

Closed
tapesclub opened this issue Oct 19, 2017 · 5 comments
Closed

market orders aren't working #2

tapesclub opened this issue Oct 19, 2017 · 5 comments
Assignees

Comments

@tapesclub
Copy link

Hi, the example code to place a market order doesn't work—I'm not sure why, but it seems to be sending price information, which the api isn't expecting. Limit orders work fine.

Here's the error code I receive:

BUY(BNBBTC,1,0) { code: -1104,
msg: 'Not all sent parameters were not read; read '9' parameter(s) but was sent '10'.' }

@jaggedsoft
Copy link
Owner

Thank you for the report!
I created an update that fixes this issue. Please issue an npm update in your project directory.

I have verified it works with the following code:

const binance = require('node-binance-api');
binance.options({
  'APIKEY':'key',
  'APISECRET':'secret'
});
//Placing a MARKET order
var symbol = "BNBBTC", quantity = 1;
binance.buy(symbol, quantity, 0, {type:"MARKET"});

@tapesclub
Copy link
Author

tapesclub commented Oct 20, 2017 via email

@jaggedsoft
Copy link
Owner

Thank you!
And great idea. I will work on this and keep you updated

@jaggedsoft jaggedsoft reopened this Oct 21, 2017
@jaggedsoft
Copy link
Owner

Thank you for the suggestion!

I added callbacks to buy/sell functions and added a shortcut to make market orders easier. Now you can chain orders together.

var quantity = 1;
binance.marketBuy("BNBBTC", quantity, function(response) {
	console.log("Market Buy response", response);
	// Now you can limit sell with a stop loss, etc.
});

Any other features/bugs/suggestions let me know and I will be happy to help. If you open it as a new issue I will see it sooner. Thanks again!

@jaggedsoft
Copy link
Owner

Here are some new examples

Limit Buy

var quantity = 5, price = 0.00402030;
binance.buy("BNBETH", quantity, price, {}, function(response) {
	console.log("Limit Buy response", response);
	console.log("order id: " + response.orderId);
});
Limit Buy response { symbol: 'BNBETH',
  orderId: 4480717,
  clientOrderId: 'te38xGILZUXrPZHnTQPH6h',
  transactTime: 1509049732437,
  price: '0.00402030',
  origQty: '5.00000000',
  executedQty: '5.00000000',
  status: 'FILLED',
  timeInForce: 'GTC',
  type: 'LIMIT',
  side: 'BUY' }
//order id: 4480717

Market Buy

var quantity = 1;
binance.marketBuy("BNBBTC", quantity, function(response) {
	console.log("Market Buy response", response);
	console.log("order id: " + response.orderId)
	// Now you can limit sell with a stop loss, etc.
});
Market Buy response {
  symbol: 'BNBETH',
  orderId: 4480553,
  clientOrderId: 'rCGiCG08PGy7AwvbrG5d83',
  transactTime: 1509049376261,
  price: '0.00000000',
  origQty: '1.00000000',
  executedQty: '1.00000000',
  status: 'FILLED',
  timeInForce: 'GTC',
  type: 'MARKET',
  side: 'BUY' }
//order id: 4480553

Please navigate to your project directory and issue an npm update
Or run the command npm install node-binance-api --save

jaggedsoft pushed a commit that referenced this issue Jan 7, 2018
Remove static badges
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants