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

Method create_order

python/ccxt/async_support/bingx.py:3098–3228  ·  view source on GitHub ↗

create a trade order https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Place%20order https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Place%20order https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Place%20TWAP%20Order

(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})

Source from the content-addressed store, hash-verified

3096 return self.extend(request, params)
3097
3098 async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
3099 """
3100 create a trade order
3101
3102 https://bingx-api.github.io/docs-v3/#/en/Spot/Trades%20Endpoints/Place%20order
3103 https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Place%20order
3104 https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Place%20TWAP%20Order
3105 https://bingx-api.github.io/docs-v3/#/en/Coin-M%20Futures/Trades%20Endpoints/Trade%20order
3106
3107 :param str symbol: unified symbol of the market to create an order in
3108 :param str type: 'market' or 'limit'
3109 :param str side: 'buy' or 'sell'
3110 :param float amount: how much you want to trade in units of the base currency
3111 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
3112 :param dict [params]: extra parameters specific to the exchange API endpoint
3113 :param str [params.clientOrderId]: a unique id for the order
3114 :param bool [params.postOnly]: True to place a post only order
3115 :param str [params.timeInForce]: spot supports 'PO', 'GTC' and 'IOC', swap supports 'PO', 'GTC', 'IOC' and 'FOK'
3116 :param bool [params.reduceOnly]: *swap only* True or False whether the order is reduce only
3117 :param float [params.triggerPrice]: triggerPrice at which the attached take profit / stop loss order will be triggered
3118 :param float [params.stopLossPrice]: stop loss trigger price
3119 :param float [params.takeProfitPrice]: take profit trigger price
3120 :param float [params.cost]: the quote quantity that can be used alternative for the amount
3121 :param float [params.trailingAmount]: *swap only* the quote amount to trail away from the current market price
3122 :param float [params.trailingPercent]: *swap only* the percent to trail away from the current market price
3123 :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
3124 :param float [params.takeProfit.triggerPrice]: take profit trigger price
3125 :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
3126 :param float [params.stopLoss.triggerPrice]: stop loss trigger price
3127 :param boolean [params.test]: *swap only* whether to use the test endpoint or not, default is False
3128 :param str [params.positionSide]: *contracts only* "BOTH" for one way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
3129 :param boolean [params.hedged]: *swap only* whether the order is in hedged mode or one way mode
3130 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
3131 """
3132 await self.load_markets()
3133 market = self.market(symbol)
3134 test = self.safe_bool(params, 'test', False)
3135 params = self.omit(params, 'test')
3136 request = self.create_order_request(symbol, type, side, amount, price, params)
3137 response = None
3138 if market['swap']:
3139 if test:
3140 response = await self.swapV2PrivatePostTradeOrderTest(request)
3141 elif market['inverse']:
3142 response = await self.cswapV1PrivatePostTradeOrder(request)
3143 elif type == 'twap':
3144 response = await self.swapV1PrivatePostTwapOrder(request)
3145 else:
3146 response = await self.swapV2PrivatePostTradeOrder(request)
3147 else:
3148 response = await self.spotV1PrivatePostTradeOrder(request)
3149 #
3150 # spot
3151 #
3152 # {
3153 # "code": 0,
3154 # "msg": "",
3155 # "data": {

Calls 14

create_order_requestMethod · 0.95
parse_orderMethod · 0.95
safe_boolMethod · 0.80
parse_jsonMethod · 0.80
safe_dictMethod · 0.80
load_marketsMethod · 0.45

Tested by

no test coverage detected