MCPcopy Index your code
hub / github.com/ccxt/node-binance-api / marginOrder

Function marginOrder

deprecated/node-binance-api.js:450–501  ·  view source on GitHub ↗
(side, symbol, quantity, price, flags = {}, callback = false)

Source from the content-addressed store, hash-verified

448 * @return {undefined}
449 */
450 const marginOrder = (side, symbol, quantity, price, flags = {}, callback = false) => {
451 let endpoint = 'v1/margin/order';
452 if (Binance.options.test) endpoint += '/test';
453 let opt = {
454 symbol: symbol,
455 side: side,
456 type: 'LIMIT',
457 quantity: quantity
458 };
459 if (typeof flags.type !== 'undefined') opt.type = flags.type;
460 if (typeof flags.isIsolated !== 'undefined') opt.isIsolated = flags.isIsolated;
461 if (opt.type.includes('LIMIT')) {
462 opt.price = price;
463 if (opt.type !== 'LIMIT_MAKER') {
464 opt.timeInForce = 'GTC';
465 }
466 }
467
468 if (typeof flags.timeInForce !== 'undefined') opt.timeInForce = flags.timeInForce;
469 if (typeof flags.newOrderRespType !== 'undefined') opt.newOrderRespType = flags.newOrderRespType;
470 // if ( typeof flags.newClientOrderId !== 'undefined' ) opt.newClientOrderId = flags.newClientOrderId;
471 if (typeof flags.newClientOrderId !== 'undefined') {
472 opt.newClientOrderId = flags.newClientOrderId;
473 } else {
474 opt.newClientOrderId = SPOT_PREFIX + uuid22();
475 }
476 if (typeof flags.sideEffectType !== 'undefined') opt.sideEffectType = flags.sideEffectType;
477
478 /*
479 * STOP_LOSS
480 * STOP_LOSS_LIMIT
481 * TAKE_PROFIT
482 * TAKE_PROFIT_LIMIT
483 */
484 if (typeof flags.icebergQty !== 'undefined') opt.icebergQty = flags.icebergQty;
485 if (typeof flags.stopPrice !== 'undefined') {
486 opt.stopPrice = flags.stopPrice;
487 if (opt.type === 'LIMIT') throw Error('stopPrice: Must set "type" to one of the following: STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT');
488 }
489 signedRequest(sapi + endpoint, opt, function (error, response) {
490 if (!response) {
491 if (callback) callback(error, response);
492 else Binance.options.log('Order() error:', error);
493 return;
494 }
495 if (typeof response.msg !== 'undefined' && response.msg === 'Filter failure: MIN_NOTIONAL') {
496 Binance.options.log('Order quantity too small. See exchangeInfo() for minimum amounts');
497 }
498 if (callback) callback(error, response);
499 else Binance.options.log(side + '(' + symbol + ',' + quantity + ',' + price + ') ', response);
500 }, 'POST');
501 };
502
503 // Futures internal functions
504 const futuresOrder = async (side, symbol, quantity, price = false, params = {}) => {

Callers 1

apiFunction · 0.85

Calls 3

uuid22Function · 0.85
signedRequestFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected