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

Method create_order

python/ccxt/bingx.py:3097–3227  ·  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

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