create a trade order https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd https://documenter.getpostman.com/view/10287440/SzYXWKPi#de6f4321-eeac-468c-87f7-c4ad7062e265 # stop market https://documenter.getpostman.com/view/102
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 1508 | return await self.create_order(symbol, 'market', 'sell', cost, None, params) |
| 1509 | |
| 1510 | async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 1511 | """ |
| 1512 | create a trade order |
| 1513 | |
| 1514 | https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd |
| 1515 | https://documenter.getpostman.com/view/10287440/SzYXWKPi#de6f4321-eeac-468c-87f7-c4ad7062e265 # stop market |
| 1516 | https://documenter.getpostman.com/view/10287440/SzYXWKPi#3561b86c-9ff1-436e-8e68-ac926b7eb523 # margin |
| 1517 | |
| 1518 | :param str symbol: unified symbol of the market to create an order in |
| 1519 | :param str type: 'market' or 'limit' |
| 1520 | :param str side: 'buy' or 'sell' |
| 1521 | :param float amount: how much of currency you want to trade in units of base currency |
| 1522 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 1523 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1524 | :param float [params.triggerPrice]: the price at which a trigger order is triggered at |
| 1525 | :param str [params.timeInForce]: *spot only* 'fok', 'ioc' or 'post_only' |
| 1526 | :param boolean [params.postOnly]: *spot only* True for post only orders |
| 1527 | :param float [params.cost]: *spot only* *market orders only* the cost of the order in the quote currency for market orders |
| 1528 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 1529 | """ |
| 1530 | await self.load_markets() |
| 1531 | market = self.market(symbol) |
| 1532 | isMarket = (type == 'market') and (price is None) |
| 1533 | marginMode = None |
| 1534 | marginMode, params = self.handle_margin_mode_and_params('createOrder', params) |
| 1535 | if marginMode == 'cross': |
| 1536 | raise BadRequest(self.id + ' only supports isolated margin') |
| 1537 | isSpot = (marginMode != 'isolated') |
| 1538 | triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPrice', 'stop_price']) |
| 1539 | cost = self.safe_string(params, 'cost') |
| 1540 | request = { |
| 1541 | 'pair': market['id'], |
| 1542 | # 'leverage': 2, |
| 1543 | # 'quantity': self.amount_to_precision(market['symbol'], amount), |
| 1544 | # spot - buy, sell, market_buy, market_sell, market_buy_total, market_sell_total |
| 1545 | # margin - limit_buy, limit_sell, market_buy, market_sell, stop_buy, stop_sell, stop_limit_buy, stop_limit_sell, trailing_stop_buy, trailing_stop_sell |
| 1546 | # 'stop_price': self.price_to_precision(symbol, stopPrice), |
| 1547 | # 'distance': 0, # distance for trailing stop orders |
| 1548 | # 'expire': 0, # expiration timestamp in UTC timezone for the order, unless expire is 0 |
| 1549 | # 'client_id': 123, # optional, must be a positive integer |
| 1550 | # 'comment': '', # up to 50 latin symbols, whitespaces, underscores |
| 1551 | } |
| 1552 | if cost is None: |
| 1553 | request['quantity'] = self.amount_to_precision(market['symbol'], amount) |
| 1554 | else: |
| 1555 | request['quantity'] = self.cost_to_precision(market['symbol'], cost) |
| 1556 | clientOrderId = self.safe_value_2(params, 'client_id', 'clientOrderId') |
| 1557 | if clientOrderId is not None: |
| 1558 | clientOrderId = self.safe_integer_2(params, 'client_id', 'clientOrderId') |
| 1559 | if clientOrderId is None: |
| 1560 | raise BadRequest(self.id + ' createOrder() client order id must be an integer / numeric literal') |
| 1561 | else: |
| 1562 | request['client_id'] = clientOrderId |
| 1563 | leverage = self.safe_number(params, 'leverage') |
| 1564 | if not isSpot and (leverage is None): |
| 1565 | raise ArgumentsRequired(self.id + ' createOrder requires an extra param params["leverage"] for margin orders') |
| 1566 | params = self.omit(params, ['stopPrice', 'stop_price', 'triggerPrice', 'timeInForce', 'client_id', 'clientOrderId', 'cost']) |
| 1567 | if price is not None: |
no test coverage detected