MCPcopy Create free account
hub / github.com/ccxt/ccxt / create_order

Method create_order

python/ccxt/exmo.py:1509–1608  ·  view source on GitHub ↗

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={})

Source from the content-addressed store, hash-verified

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

Calls 15

parse_orderMethod · 0.95
BadRequestClass · 0.90
ArgumentsRequiredClass · 0.90
safe_string_nMethod · 0.80
safe_stringMethod · 0.80
safe_value_2Method · 0.80
safe_integer_2Method · 0.80
safe_numberMethod · 0.80
handle_post_onlyMethod · 0.80

Tested by

no test coverage detected