create a trade order https://www.bitrue.com/api_docs_includes_file/spot/index.html#new-order-trade https://www.bitrue.com/api_docs_includes_file/futures/index.html#new-order-trade-hmac-sha256 :param str symbol: unified symbol of the market to create an order in
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 1956 | return self.create_order(symbol, 'market', 'buy', cost, None, params) |
| 1957 | |
| 1958 | def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 1959 | """ |
| 1960 | create a trade order |
| 1961 | |
| 1962 | https://www.bitrue.com/api_docs_includes_file/spot/index.html#new-order-trade |
| 1963 | https://www.bitrue.com/api_docs_includes_file/futures/index.html#new-order-trade-hmac-sha256 |
| 1964 | |
| 1965 | :param str symbol: unified symbol of the market to create an order in |
| 1966 | :param str type: 'market' or 'limit' |
| 1967 | :param str side: 'buy' or 'sell' |
| 1968 | :param float amount: how much of currency you want to trade in units of base currency |
| 1969 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 1970 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1971 | :param float [params.triggerPrice]: *spot only* the price at which a trigger order is triggered at |
| 1972 | :param str [params.clientOrderId]: a unique id for the order, automatically generated if not sent |
| 1973 | :param decimal [params.leverage]: in future order, the leverage value of the order should consistent with the user contract configuration, default is 1 |
| 1974 | :param str [params.timeInForce]: 'fok', 'ioc' or 'po' |
| 1975 | :param bool [params.postOnly]: default False |
| 1976 | :param bool [params.reduceOnly]: default False |
| 1977 | EXCHANGE SPECIFIC PARAMETERS |
| 1978 | :param decimal [params.icebergQty]: |
| 1979 | :param long [params.recvWindow]: |
| 1980 | :param float [params.cost]: *swap market buy only* the quote quantity that can be used alternative for the amount |
| 1981 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 1982 | """ |
| 1983 | self.load_markets() |
| 1984 | market = self.market(symbol) |
| 1985 | response = None |
| 1986 | data = {} |
| 1987 | uppercaseType = type.upper() |
| 1988 | request = { |
| 1989 | 'side': side.upper(), |
| 1990 | 'type': uppercaseType, |
| 1991 | # 'timeInForce': '', |
| 1992 | # 'price': self.price_to_precision(symbol, price), |
| 1993 | # 'newClientOrderId': clientOrderId, # automatically generated if not sent |
| 1994 | # 'stopPrice': self.price_to_precision(symbol, 'stopPrice'), |
| 1995 | # 'icebergQty': self.amount_to_precision(symbol, icebergQty), |
| 1996 | } |
| 1997 | if uppercaseType == 'LIMIT': |
| 1998 | if price is None: |
| 1999 | raise InvalidOrder(self.id + ' createOrder() requires a price argument') |
| 2000 | request['price'] = self.price_to_precision(symbol, price) |
| 2001 | if market['swap']: |
| 2002 | isMarket = uppercaseType == 'MARKET' |
| 2003 | timeInForce = self.safe_string_lower(params, 'timeInForce') |
| 2004 | postOnly = self.is_post_only(isMarket, None, params) |
| 2005 | if postOnly: |
| 2006 | request['type'] = 'POST_ONLY' |
| 2007 | elif timeInForce == 'fok': |
| 2008 | request['type'] = 'FOK' |
| 2009 | elif timeInForce == 'ioc': |
| 2010 | request['type'] = 'IOC' |
| 2011 | request['contractName'] = market['id'] |
| 2012 | createMarketBuyOrderRequiresPrice = True |
| 2013 | createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True) |
| 2014 | if isMarket and (side == 'buy') and createMarketBuyOrderRequiresPrice: |
| 2015 | cost = self.safe_string(params, 'cost') |
no test coverage detected