@ignore helper function to build request for editSpotOrder :param str id: order id to be edited :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_P
(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 5247 | return self.parse_order(data, market) |
| 5248 | |
| 5249 | def edit_spot_order_request(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 5250 | """ |
| 5251 | @ignore |
| 5252 | helper function to build request for editSpotOrder |
| 5253 | :param str id: order id to be edited |
| 5254 | :param str symbol: unified symbol of the market to create an order in |
| 5255 | :param str type: 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP' |
| 5256 | :param str side: 'buy' or 'sell' |
| 5257 | :param float amount: how much of currency you want to trade in units of base currency |
| 5258 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 5259 | :param dict params: extra parameters specific to the exchange API endpoint |
| 5260 | :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading |
| 5261 | :returns dict: request to be sent to the exchange |
| 5262 | """ |
| 5263 | market = self.market(symbol) |
| 5264 | clientOrderId = self.safe_string_n(params, ['newClientOrderId', 'clientOrderId', 'origClientOrderId']) |
| 5265 | request = { |
| 5266 | 'symbol': market['id'], |
| 5267 | 'side': side.upper(), |
| 5268 | } |
| 5269 | initialUppercaseType = type.upper() |
| 5270 | uppercaseType = initialUppercaseType |
| 5271 | postOnly = self.is_post_only(initialUppercaseType == 'MARKET', initialUppercaseType == 'LIMIT_MAKER', params) |
| 5272 | if postOnly: |
| 5273 | uppercaseType = 'LIMIT_MAKER' |
| 5274 | triggerPrice = self.safe_number_2(params, 'stopPrice', 'triggerPrice') |
| 5275 | if triggerPrice is not None: |
| 5276 | if uppercaseType == 'MARKET': |
| 5277 | uppercaseType = 'STOP_LOSS' |
| 5278 | elif uppercaseType == 'LIMIT': |
| 5279 | uppercaseType = 'STOP_LOSS_LIMIT' |
| 5280 | request['type'] = uppercaseType |
| 5281 | validOrderTypes = self.safe_list(market['info'], 'orderTypes') |
| 5282 | if not self.in_array(uppercaseType, validOrderTypes): |
| 5283 | if initialUppercaseType != uppercaseType: |
| 5284 | raise InvalidOrder(self.id + ' triggerPrice parameter is not allowed for ' + symbol + ' ' + type + ' orders') |
| 5285 | else: |
| 5286 | raise InvalidOrder(self.id + ' ' + type + ' is not a valid order type for the ' + symbol + ' market') |
| 5287 | if clientOrderId is None: |
| 5288 | broker = self.safe_dict(self.options, 'broker') |
| 5289 | if broker is not None: |
| 5290 | brokerId = self.safe_string(broker, 'spot') |
| 5291 | if brokerId is not None: |
| 5292 | request['newClientOrderId'] = brokerId + self.uuid22() |
| 5293 | else: |
| 5294 | request['newClientOrderId'] = clientOrderId |
| 5295 | request['newOrderRespType'] = self.safe_value(self.options['newOrderRespType'], type, 'RESULT') # 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills |
| 5296 | timeInForceIsRequired = False |
| 5297 | priceIsRequired = False |
| 5298 | triggerPriceIsRequired = False |
| 5299 | quantityIsRequired = False |
| 5300 | if uppercaseType == 'MARKET': |
| 5301 | quoteOrderQty = self.safe_bool(self.options, 'quoteOrderQty', True) |
| 5302 | if quoteOrderQty: |
| 5303 | quoteOrderQtyNew = self.safe_value_2(params, 'quoteOrderQty', 'cost') |
| 5304 | precision = market['precision']['price'] |
| 5305 | if quoteOrderQtyNew is not None: |
| 5306 | request['quoteOrderQty'] = self.decimal_to_precision(quoteOrderQtyNew, TRUNCATE, precision, self.precisionMode) |
no test coverage detected