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

Method create_order

python/ccxt/bullish.py:1672–1729  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

handle_tokenMethod · 0.95
load_accountMethod · 0.95
parse_orderMethod · 0.95
NotSupportedClass · 0.90
handle_post_onlyMethod · 0.80
safe_stringMethod · 0.80
privatePostV2OrdersMethod · 0.65
load_marketsMethod · 0.45
marketMethod · 0.45
amount_to_precisionMethod · 0.45
price_to_precisionMethod · 0.45

Tested by

no test coverage detected