create a trade order https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#post-/v2/orders :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or 'limit' or 'STOP_LIMIT' or 'POST_ONLY' :param str side: 'b
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 1671 | return self.parse_order(response, market) |
| 1672 | |
| 1673 | async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> Order: |
| 1674 | """ |
| 1675 | create a trade order |
| 1676 | |
| 1677 | https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#post-/v2/orders |
| 1678 | |
| 1679 | :param str symbol: unified symbol of the market to create an order in |
| 1680 | :param str type: 'market' or 'limit' or 'STOP_LIMIT' or 'POST_ONLY' |
| 1681 | :param str side: 'buy' or 'sell' |
| 1682 | :param float amount: how much of currency you want to trade in units of base currency |
| 1683 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 1684 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1685 | :param str [params.clientOrderId]: a custom client order id |
| 1686 | :param float [params.triggerPrice]: the price at which a stop order is triggered at |
| 1687 | :param str [params.timeInForce]: the time in force for the order, either 'GTC'(Good Till Cancelled) or 'IOC'(Immediate or Cancel), default is 'GTC' |
| 1688 | :param bool [params.allowBorrow]: if True, the order will be allowed to borrow assets to fulfill the order(default is False) |
| 1689 | :param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately(default is False) |
| 1690 | :param str params['traidingAccountId']: the trading account id(mandatory parameter) |
| 1691 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 1692 | """ |
| 1693 | await asyncio.gather(*[self.load_markets(), self.handle_token()]) |
| 1694 | tradingAccountId = await self.load_account(params) |
| 1695 | market = self.market(symbol) |
| 1696 | request = { |
| 1697 | 'commandType': 'V3CreateOrder', |
| 1698 | 'symbol': market['id'], |
| 1699 | 'side': side.upper(), |
| 1700 | 'quantity': self.amount_to_precision(symbol, amount), |
| 1701 | 'tradingAccountId': tradingAccountId, |
| 1702 | } |
| 1703 | isMarketOrder = ((type == 'market') or type == 'MARKET') |
| 1704 | postOnly = False |
| 1705 | postOnly, params = self.handle_post_only(isMarketOrder, type == 'POST_ONLY', params) |
| 1706 | if postOnly: |
| 1707 | type = 'POST_ONLY' |
| 1708 | timeInForce = 'GTC' # is mandatory |
| 1709 | timeInForce, params = self.handle_option_and_params(params, 'createOrder', 'timeInForce', timeInForce) |
| 1710 | params['timeInForce'] = timeInForce.upper() |
| 1711 | if not isMarketOrder: |
| 1712 | request['price'] = self.price_to_precision(symbol, price) |
| 1713 | triggerPrice = self.safe_string(params, 'triggerPrice') |
| 1714 | if triggerPrice is not None: |
| 1715 | if isMarketOrder: |
| 1716 | raise NotSupported(self.id + ' createOrder() does not support market trigger orders') |
| 1717 | request['stopPrice'] = self.price_to_precision(symbol, triggerPrice) |
| 1718 | type = 'STOP_LIMIT' |
| 1719 | params = self.omit(params, 'triggerPrice') |
| 1720 | request['type'] = type.upper() |
| 1721 | response = await self.privatePostV2Orders(self.extend(request, params)) |
| 1722 | # |
| 1723 | # { |
| 1724 | # "message": "Command acknowledged - CreateOrder", |
| 1725 | # "requestId": "633910976353665024", |
| 1726 | # "orderId": "633910775316480001", |
| 1727 | # "clientOrderId": "1234567" |
| 1728 | # } |
| 1729 | # |
| 1730 | return self.parse_order(response, market) |
nothing calls this directly
no test coverage detected