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

Method create_order

python/ccxt/async_support/bitget.py:4930–5028  ·  view source on GitHub ↗

create a trade order https://www.bitget.com/api-doc/spot/trade/Place-Order https://www.bitget.com/api-doc/spot/plan/Place-Plan-Order https://www.bitget.com/api-doc/contract/trade/Place-Order https://www.bitget.com/api-doc/contract/plan/Place-Tpsl-Order

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

Source from the content-addressed store, hash-verified

4928 return await self.create_order(symbol, 'market', 'buy', cost, None, self.extend(req, params))
4929
4930 async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4931 """
4932 create a trade order
4933
4934 https://www.bitget.com/api-doc/spot/trade/Place-Order
4935 https://www.bitget.com/api-doc/spot/plan/Place-Plan-Order
4936 https://www.bitget.com/api-doc/contract/trade/Place-Order
4937 https://www.bitget.com/api-doc/contract/plan/Place-Tpsl-Order
4938 https://www.bitget.com/api-doc/contract/plan/Place-Plan-Order
4939 https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
4940 https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
4941 https://www.bitget.com/api-doc/uta/trade/Place-Order
4942 https://www.bitget.com/api-doc/uta/strategy/Place-Strategy-Order
4943
4944 :param str symbol: unified symbol of the market to create an order in
4945 :param str type: 'market' or 'limit'
4946 :param str side: 'buy' or 'sell'
4947 :param float amount: how much you want to trade in units of the base currency
4948 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders, and used execution price for contract stop-loss / take-profit orders
4949 :param dict [params]: extra parameters specific to the exchange API endpoint
4950 :param float [params.cost]: *spot only* how much you want to trade in units of the quote currency, for market buy orders only
4951 :param float [params.triggerPrice]: *swap only* The price at which a trigger order is triggered at
4952 :param float [params.stopLossPrice]: *swap only* The price at which a stop loss order is triggered at
4953 :param float [params.takeProfitPrice]: *swap only* The price at which a take profit order is triggered at
4954 :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
4955 :param float [params.takeProfit.triggerPrice]: *swap only* take profit trigger price
4956 :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
4957 :param float [params.stopLoss.triggerPrice]: *swap only* stop loss trigger price
4958 :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
4959 :param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
4960 :param str [params.loanType]: *spot margin only* 'normal', 'autoLoan', 'autoRepay', or 'autoLoanAndRepay' default is 'normal'
4961 :param str [params.holdSide]: *contract stopLossPrice, takeProfitPrice only* Two-way position: ('long' or 'short'), one-way position: ('buy' or 'sell')
4962 :param float [params.stopLoss.price]: *swap only* the execution price for a stop loss attached to a trigger order
4963 :param float [params.takeProfit.price]: *swap only* the execution price for a take profit attached to a trigger order
4964 :param str [params.stopLoss.type]: *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
4965 :param str [params.takeProfit.type]: *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
4966 :param str [params.trailingPercent]: *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
4967 :param str [params.trailingTriggerPrice]: *swap and future only* the price to trigger a trailing stop order, default uses the price argument
4968 :param str [params.triggerType]: *swap and future only* 'fill_price', 'mark_price' or 'index_price'
4969 :param boolean [params.oneWayMode]: *swap and future only* required to set self to True in one_way_mode and you can leave self in hedge_mode, can adjust the mode using the setPositionMode() method
4970 :param bool [params.hedged]: *swap and future only* True for hedged mode, False for one way mode, default is False
4971 :param bool [params.reduceOnly]: True or False whether the order is reduce-only
4972 :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
4973 :param str [params.posSide]: *uta only* hedged two-way position side, long or short
4974 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
4975 """
4976 await self.load_markets()
4977 market = self.market(symbol)
4978 marginParams = self.handle_margin_mode_and_params('createOrder', params)
4979 marginMode = marginParams[0]
4980 triggerPrice = self.safe_value_2(params, 'stopPrice', 'triggerPrice')
4981 stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
4982 takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
4983 trailingPercent = self.safe_string_2(params, 'trailingPercent', 'callbackRatio')
4984 isTrailingPercentOrder = trailingPercent is not None
4985 isTriggerOrder = triggerPrice is not None
4986 isStopLossTriggerOrder = stopLossTriggerPrice is not None
4987 isTakeProfitTriggerOrder = takeProfitTriggerPrice is not None

Callers 1

Tested by

no test coverage detected