(side, symbol, quantity, price = false, params = {})
| 502 | |
| 503 | // Futures internal functions |
| 504 | const futuresOrder = async (side, symbol, quantity, price = false, params = {}) => { |
| 505 | params.symbol = symbol; |
| 506 | params.side = side; |
| 507 | if (quantity) params.quantity = quantity; |
| 508 | // if in the binance futures setting Hedged mode is active, positionSide parameter is mandatory |
| 509 | if (typeof params.positionSide === 'undefined' && Binance.options.hedgeMode) { |
| 510 | params.positionSide = side === 'BUY' ? 'LONG' : 'SHORT'; |
| 511 | } |
| 512 | // LIMIT STOP MARKET STOP_MARKET TAKE_PROFIT TAKE_PROFIT_MARKET |
| 513 | // reduceOnly stopPrice |
| 514 | if (price) { |
| 515 | params.price = price; |
| 516 | if (typeof params.type === 'undefined') params.type = 'LIMIT'; |
| 517 | } else { |
| 518 | if (typeof params.type === 'undefined') params.type = 'MARKET'; |
| 519 | } |
| 520 | if (!params.timeInForce && (params.type.includes('LIMIT') || params.type === 'STOP' || params.type === 'TAKE_PROFIT')) { |
| 521 | params.timeInForce = 'GTX'; // Post only by default. Use GTC for limit orders. |
| 522 | } |
| 523 | |
| 524 | if (!params.newClientOrderId) { |
| 525 | params.newClientOrderId = CONTRACT_PREFIX + uuid22(); |
| 526 | } |
| 527 | |
| 528 | return promiseRequest('v1/order', params, { base: fapi, type: 'TRADE', method: 'POST' }); |
| 529 | }; |
| 530 | const deliveryOrder = async (side, symbol, quantity, price = false, params = {}) => { |
| 531 | params.symbol = symbol; |
| 532 | params.side = side; |
no test coverage detected