create a trade order https://docs.whitebit.com/private/http-trade-v4/#create-limit-order https://docs.whitebit.com/private/http-trade-v4/#create-market-order https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order https://docs.whitebit
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 1878 | return self.create_market_order_with_cost(symbol, 'buy', cost, params) |
| 1879 | |
| 1880 | def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 1881 | """ |
| 1882 | create a trade order |
| 1883 | |
| 1884 | https://docs.whitebit.com/private/http-trade-v4/#create-limit-order |
| 1885 | https://docs.whitebit.com/private/http-trade-v4/#create-market-order |
| 1886 | https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order |
| 1887 | https://docs.whitebit.com/private/http-trade-v4/#create-stop-limit-order |
| 1888 | https://docs.whitebit.com/private/http-trade-v4/#create-stop-market-order |
| 1889 | |
| 1890 | :param str symbol: unified symbol of the market to create an order in |
| 1891 | :param str type: 'market' or 'limit' |
| 1892 | :param str side: 'buy' or 'sell' |
| 1893 | :param float amount: how much of currency you want to trade in units of base currency |
| 1894 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 1895 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1896 | :param float [params.cost]: *market orders only* the cost of the order in units of the base currency |
| 1897 | :param float [params.triggerPrice]: The price at which a trigger order is triggered at |
| 1898 | :param bool [params.postOnly]: If True, the order will only be posted to the order book and not executed immediately |
| 1899 | :param str [params.clientOrderId]: a unique id for the order |
| 1900 | :param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None |
| 1901 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 1902 | """ |
| 1903 | self.load_markets() |
| 1904 | market = self.market(symbol) |
| 1905 | request = { |
| 1906 | 'market': market['id'], |
| 1907 | 'side': side, |
| 1908 | } |
| 1909 | cost = None |
| 1910 | cost, params = self.handle_param_string(params, 'cost') |
| 1911 | if cost is not None: |
| 1912 | if (side != 'buy') or (type != 'market'): |
| 1913 | raise InvalidOrder(self.id + ' createOrder() cost is only supported for market buy orders') |
| 1914 | request['amount'] = self.cost_to_precision(symbol, cost) |
| 1915 | else: |
| 1916 | request['amount'] = self.amount_to_precision(symbol, amount) |
| 1917 | clientOrderId = self.safe_string_2(params, 'clOrdId', 'clientOrderId') |
| 1918 | if clientOrderId is None: |
| 1919 | brokerId = self.safe_string(self.options, 'brokerId') |
| 1920 | if brokerId is not None: |
| 1921 | request['clientOrderId'] = brokerId + self.uuid16() |
| 1922 | else: |
| 1923 | request['clientOrderId'] = clientOrderId |
| 1924 | params = self.omit(params, ['clientOrderId']) |
| 1925 | marketType = self.safe_string(market, 'type') |
| 1926 | isLimitOrder = type == 'limit' |
| 1927 | isMarketOrder = type == 'market' |
| 1928 | triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'activation_price']) |
| 1929 | isStopOrder = (triggerPrice is not None) |
| 1930 | postOnly = self.is_post_only(isMarketOrder, False, params) |
| 1931 | marginMode, query = self.handle_margin_mode_and_params('createOrder', params) |
| 1932 | if postOnly: |
| 1933 | request['postOnly'] = True |
| 1934 | if marginMode is not None and marginMode != 'cross': |
| 1935 | raise NotSupported(self.id + ' createOrder() is only available for cross margin') |
| 1936 | params = self.omit(query, ['postOnly', 'triggerPrice', 'stopPrice']) |
| 1937 | useCollateralEndpoint = marginMode is not None or marketType == 'swap' |
no test coverage detected