(symbol, type, side, amount, price = undefined, params = {})
| 2998 | return await this.createOrder(symbol, 'market', 'sell', cost, undefined, params); |
| 2999 | } |
| 3000 | createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) { |
| 3001 | /** |
| 3002 | * @method |
| 3003 | * @ignore |
| 3004 | * @name bingx#createOrderRequest |
| 3005 | * @description helper function to build request |
| 3006 | * @param {string} symbol unified symbol of the market to create an order in |
| 3007 | * @param {string} type 'market' or 'limit' |
| 3008 | * @param {string} side 'buy' or 'sell' |
| 3009 | * @param {float} amount how much you want to trade in units of the base currency |
| 3010 | * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 3011 | * @param {object} [params] extra parameters specific to the exchange API endpoint |
| 3012 | * @returns {object} request to be sent to the exchange |
| 3013 | */ |
| 3014 | const market = this.market(symbol); |
| 3015 | let postOnly = undefined; |
| 3016 | let marketType = undefined; |
| 3017 | [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params); |
| 3018 | type = type.toUpperCase(); |
| 3019 | const request = { |
| 3020 | 'symbol': market['id'], |
| 3021 | 'type': type, |
| 3022 | 'side': side.toUpperCase(), |
| 3023 | }; |
| 3024 | const isMarketOrder = type === 'MARKET'; |
| 3025 | const isSpot = marketType === 'spot'; |
| 3026 | const isTwapOrder = type === 'TWAP'; |
| 3027 | if (isTwapOrder && isSpot) { |
| 3028 | throw new BadSymbol(this.id + ' createOrder() twap order supports swap contracts only'); |
| 3029 | } |
| 3030 | const stopLossPrice = this.safeString(params, 'stopLossPrice'); |
| 3031 | const takeProfitPrice = this.safeString(params, 'takeProfitPrice'); |
| 3032 | const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice'); |
| 3033 | const isTriggerOrder = triggerPrice !== undefined; |
| 3034 | const isStopLossPriceOrder = stopLossPrice !== undefined; |
| 3035 | const isTakeProfitPriceOrder = takeProfitPrice !== undefined; |
| 3036 | const exchangeClientOrderId = isSpot ? 'newClientOrderId' : 'clientOrderID'; |
| 3037 | const clientOrderId = this.safeString2(params, exchangeClientOrderId, 'clientOrderId'); |
| 3038 | if (clientOrderId !== undefined) { |
| 3039 | request[exchangeClientOrderId] = clientOrderId; |
| 3040 | } |
| 3041 | const timeInForce = this.safeStringUpper(params, 'timeInForce'); |
| 3042 | [postOnly, params] = this.handlePostOnly(isMarketOrder, timeInForce === 'PostOnly', params); |
| 3043 | if (postOnly || (timeInForce === 'PostOnly')) { |
| 3044 | request['timeInForce'] = 'PostOnly'; |
| 3045 | } |
| 3046 | else if (timeInForce === 'IOC') { |
| 3047 | request['timeInForce'] = 'IOC'; |
| 3048 | } |
| 3049 | else if (timeInForce === 'GTC') { |
| 3050 | request['timeInForce'] = 'GTC'; |
| 3051 | } |
| 3052 | if (isSpot) { |
| 3053 | const cost = this.safeString2(params, 'cost', 'quoteOrderQty'); |
| 3054 | params = this.omit(params, 'cost'); |
| 3055 | if (cost !== undefined) { |
| 3056 | request['quoteOrderQty'] = this.parseToNumeric(this.costToPrecision(symbol, cost)); |
| 3057 | } |
no test coverage detected