@ignore helper function to build request :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or 'limit' or 'LIMIT_MAKER' :param str side: 'buy' or 'sell' :param float amount: how much of you want to trade in units
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 2557 | raise NotSupported(self.id + ' ' + 'createOrderRequest() is not supported for ' + market['type'] + ' type of markets') |
| 2558 | |
| 2559 | def create_spot_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> dict: |
| 2560 | """ |
| 2561 | @ignore |
| 2562 | helper function to build request |
| 2563 | :param str symbol: unified symbol of the market to create an order in |
| 2564 | :param str type: 'market' or 'limit' or 'LIMIT_MAKER' |
| 2565 | :param str side: 'buy' or 'sell' |
| 2566 | :param float amount: how much of you want to trade in units of the base currency |
| 2567 | :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 2568 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 2569 | :param float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount |
| 2570 | :param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately |
| 2571 | :param str [params.timeInForce]: "GTC", "IOC", or "PO" |
| 2572 | :param str [params.clientOrderId]: a unique id for the order |
| 2573 | :returns dict: request to be sent to the exchange |
| 2574 | """ |
| 2575 | market = self.market(symbol) |
| 2576 | type = type.upper() |
| 2577 | request = { |
| 2578 | 'symbol': market['id'], |
| 2579 | 'side': side.upper(), |
| 2580 | 'type': type, |
| 2581 | } |
| 2582 | if amount is not None: |
| 2583 | request['quantity'] = self.amount_to_precision(symbol, amount) |
| 2584 | cost = None |
| 2585 | cost, params = self.handle_param_string(params, 'cost') |
| 2586 | if cost is not None: |
| 2587 | request['quantity'] = self.cost_to_precision(symbol, cost) |
| 2588 | if price is not None: |
| 2589 | request['price'] = self.price_to_precision(symbol, price) |
| 2590 | isMarketOrder = type == 'MARKET' |
| 2591 | postOnly = False |
| 2592 | postOnly, params = self.handle_post_only(isMarketOrder, type == 'LIMIT_MAKER', params) |
| 2593 | if postOnly and (type == 'LIMIT'): |
| 2594 | request['type'] = 'LIMIT_MAKER' |
| 2595 | clientOrderId = None |
| 2596 | clientOrderId, params = self.handle_param_string(params, 'clientOrderId') |
| 2597 | if clientOrderId is not None: |
| 2598 | params['newClientOrderId'] = clientOrderId |
| 2599 | return self.extend(request, params) |
| 2600 | |
| 2601 | def create_swap_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> dict: |
| 2602 | """ |
no test coverage detected