@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' :param str side: 'buy' or 'sell' :param float amount: how much you want to trade in units of the base currency
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 4915 | return await self.create_order(symbol, type, side, amount, price, params) |
| 4916 | |
| 4917 | async def create_spot_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 4918 | """ |
| 4919 | @ignore |
| 4920 | helper function to build request |
| 4921 | :param str symbol: unified symbol of the market to create an order in |
| 4922 | :param str type: 'market' or 'limit' |
| 4923 | :param str side: 'buy' or 'sell' |
| 4924 | :param float amount: how much you want to trade in units of the base currency |
| 4925 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 4926 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 4927 | :param str [params.timeInForce]: supports 'IOC' and 'FOK' |
| 4928 | :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders |
| 4929 | :returns dict: request to be sent to the exchange |
| 4930 | """ |
| 4931 | await self.load_markets() |
| 4932 | await self.load_accounts() |
| 4933 | market = self.market(symbol) |
| 4934 | marginMode = None |
| 4935 | marginMode, params = self.handle_margin_mode_and_params('createOrder', params) |
| 4936 | accountId = await self.fetch_account_id_by_type(market['type'], marginMode, symbol) |
| 4937 | request = { |
| 4938 | # spot ----------------------------------------------------------- |
| 4939 | 'account-id': accountId, |
| 4940 | 'symbol': market['id'], |
| 4941 | # 'type': side + '-' + type, # buy-market, sell-market, buy-limit, sell-limit, buy-ioc, sell-ioc, buy-limit-maker, sell-limit-maker, buy-stop-limit, sell-stop-limit, buy-limit-fok, sell-limit-fok, buy-stop-limit-fok, sell-stop-limit-fok |
| 4942 | # 'amount': self.amount_to_precision(symbol, amount), # for buy market orders it's the order cost |
| 4943 | # 'price': self.price_to_precision(symbol, price), |
| 4944 | # 'source': 'spot-api', # optional, spot-api, margin-api = isolated margin, super-margin-api = cross margin, c2c-margin-api |
| 4945 | # 'client-order-id': clientOrderId, # optional, max 64 chars, must be unique within 8 hours |
| 4946 | # 'stop-price': self.price_to_precision(symbol, stopPrice), # trigger price for stop limit orders |
| 4947 | # 'operator': 'gte', # gte, lte, trigger price condition |
| 4948 | } |
| 4949 | orderType = type.replace('buy-', '') |
| 4950 | orderType = orderType.replace('sell-', '') |
| 4951 | options = self.safe_value(self.options, market['type'], {}) |
| 4952 | triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPrice', 'stop-price']) |
| 4953 | if triggerPrice is None: |
| 4954 | stopOrderTypes = self.safe_value(options, 'stopOrderTypes', {}) |
| 4955 | if orderType in stopOrderTypes: |
| 4956 | raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice for a trigger order') |
| 4957 | else: |
| 4958 | defaultOperator = 'lte' if (side == 'sell') else 'gte' |
| 4959 | stopOperator = self.safe_string(params, 'operator', defaultOperator) |
| 4960 | request['stop-price'] = self.price_to_precision(symbol, triggerPrice) |
| 4961 | request['operator'] = stopOperator |
| 4962 | if (orderType == 'limit') or (orderType == 'limit-fok'): |
| 4963 | orderType = 'stop-' + orderType |
| 4964 | elif (orderType != 'stop-limit') and (orderType != 'stop-limit-fok'): |
| 4965 | raise NotSupported(self.id + ' createOrder() does not support ' + type + ' orders') |
| 4966 | postOnly = None |
| 4967 | postOnly, params = self.handle_post_only(orderType == 'market', orderType == 'limit-maker', params) |
| 4968 | if postOnly: |
| 4969 | orderType = 'limit-maker' |
| 4970 | timeInForce = self.safe_string(params, 'timeInForce', 'GTC') |
| 4971 | if timeInForce == 'FOK': |
| 4972 | orderType = orderType + '-fok' |
| 4973 | elif timeInForce == 'IOC': |
| 4974 | orderType = 'ioc' |
no test coverage detected