* Create a signed margin order * @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-Order * @param {string} side - BUY or SELL * @param {string} symbol - The symbol to buy or sell * @param {string} quantity - The quantity to buy or sell * @param
(type: OrderType, side: string, symbol: string, quantity: number, price?: number, params: Dict = {})
| 1157 | * @return {undefined} |
| 1158 | */ |
| 1159 | async marginOrder(type: OrderType, side: string, symbol: string, quantity: number, price?: number, params: Dict = {}) { |
| 1160 | let endpoint = 'v1/margin/order'; |
| 1161 | if (this.Options.test || params.test) endpoint += '/test'; |
| 1162 | const request = { |
| 1163 | symbol: symbol, |
| 1164 | side: side, |
| 1165 | type: type, |
| 1166 | quantity: quantity |
| 1167 | } as Dict; |
| 1168 | if (typeof params.type !== 'undefined') request.type = params.type; |
| 1169 | if ('isIsolated' in params) request.isIsolated = params.isIsolated; |
| 1170 | if (request.type.includes('LIMIT')) { |
| 1171 | request.price = price; |
| 1172 | if (request.type !== 'LIMIT_MAKER') { |
| 1173 | request.timeInForce = 'GTC'; |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | if (typeof params.timeInForce !== 'undefined') request.timeInForce = params.timeInForce; |
| 1178 | if (typeof params.newOrderRespType !== 'undefined') request.newOrderRespType = params.newOrderRespType; |
| 1179 | // if ( typeof flags.newClientOrderId !== 'undefined' ) opt.newClientOrderId = flags.newClientOrderId; |
| 1180 | if (typeof params.newClientOrderId !== 'undefined') { |
| 1181 | request.newClientOrderId = params.newClientOrderId; |
| 1182 | } else { |
| 1183 | request.newClientOrderId = this.SPOT_PREFIX + this.uuid22(); |
| 1184 | } |
| 1185 | if (typeof params.sideEffectType !== 'undefined') request.sideEffectType = params.sideEffectType; |
| 1186 | |
| 1187 | /* |
| 1188 | * STOP_LOSS |
| 1189 | * STOP_LOSS_LIMIT |
| 1190 | * TAKE_PROFIT |
| 1191 | * TAKE_PROFIT_LIMIT |
| 1192 | */ |
| 1193 | if (typeof params.icebergQty !== 'undefined') request.icebergQty = params.icebergQty; |
| 1194 | if (typeof params.stopPrice !== 'undefined') { |
| 1195 | request.stopPrice = params.stopPrice; |
| 1196 | if (request.type === 'LIMIT') throw Error('stopPrice: Must set "type" to one of the following: STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT'); |
| 1197 | } |
| 1198 | return await this.privateSapiRequest(endpoint, this.extend(request, params), 'POST'); |
| 1199 | } |
| 1200 | |
| 1201 | // Futures internal functions |
| 1202 | /** |
no test coverage detected