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

Method create_order

python/ccxt/async_support/gate.py:4086–4217  ·  view source on GitHub ↗

Create an order on the exchange https://www.gate.com/docs/developers/apiv4/en/#create-an-order https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order https://www.gate.com/docs/developers/apiv4/en/#place-futures-order https://www.gate.com

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

Source from the content-addressed store, hash-verified

4084 }
4085
4086 async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4087 """
4088 Create an order on the exchange
4089
4090 https://www.gate.com/docs/developers/apiv4/en/#create-an-order
4091 https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order
4092 https://www.gate.com/docs/developers/apiv4/en/#place-futures-order
4093 https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order-2
4094 https://www.gate.com/docs/developers/apiv4/en/#place-futures-order-2
4095 https://www.gate.com/docs/developers/apiv4/en/#create-price-triggered-order-3
4096 https://www.gate.com/docs/developers/apiv4/en/#create-an-options-order
4097
4098 :param str symbol: Unified CCXT market symbol
4099 :param str type: 'limit' or 'market' *"market" is contract only*
4100 :param str side: 'buy' or 'sell'
4101 :param float amount: the amount of currency to trade
4102 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
4103 :param dict [params]: extra parameters specific to the exchange API endpoint
4104 :param float [params.triggerPrice]: The price at which a trigger order is triggered at
4105 :param str [params.timeInForce]: "GTC", "IOC", or "PO"
4106 :param float [params.stopLossPrice]: The price at which a stop loss order is triggered at
4107 :param float [params.takeProfitPrice]: The price at which a take profit order is triggered at
4108 :param str [params.marginMode]: 'cross' or 'isolated' - marginMode for margin trading if not provided self.options['defaultMarginMode'] is used
4109 :param int [params.iceberg]: Amount to display for the iceberg order, Null or 0 for normal orders, Set to -1 to hide the order completely
4110 :param str [params.text]: User defined information
4111 :param str [params.account]: *spot and margin only* "spot", "margin" or "cross_margin"
4112 :param bool [params.auto_borrow]: *margin only* Used in margin or cross margin trading to allow automatic loan of insufficient amount if balance is not enough
4113 :param str [params.settle]: *contract only* Unified Currency Code for settle currency
4114 :param bool [params.reduceOnly]: *contract only* Indicates if self order is to reduce the size of a position
4115 :param bool [params.close]: *contract only* Set to close the position, with size set to 0
4116 :param bool [params.auto_size]: *contract only* Set side to close dual-mode position, close_long closes the long side, while close_short the short one, size also needs to be set to 0
4117 :param int [params.price_type]: *contract only* 0 latest deal price, 1 mark price, 2 index price
4118 :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
4119 :param bool [params.unifiedAccount]: set to True for creating an order in the unified account
4120 :param str [params.clientOrderId]: the clientOrderId of the order
4121 :returns dict|None: `An order structure <https://docs.ccxt.com/?id=order-structure>`
4122 """
4123 await self.load_markets()
4124 await self.load_unified_status()
4125 market = self.market(symbol)
4126 trigger = self.safe_value(params, 'trigger')
4127 triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
4128 stopLossPrice = self.safe_value(params, 'stopLossPrice', triggerPrice)
4129 takeProfitPrice = self.safe_value(params, 'takeProfitPrice')
4130 isStopLossOrder = stopLossPrice is not None
4131 isTakeProfitOrder = takeProfitPrice is not None
4132 isTpsl = isStopLossOrder or isTakeProfitOrder
4133 nonTriggerOrder = not isTpsl and (trigger is None)
4134 orderRequest = self.create_order_request(symbol, type, side, amount, price, params)
4135 response: dict
4136 if market['spot'] or market['margin']:
4137 if nonTriggerOrder:
4138 response = await self.privateSpotPostOrders(orderRequest)
4139 else:
4140 response = await self.privateSpotPostPriceOrders(orderRequest)
4141 elif market['swap']:
4142 if nonTriggerOrder:
4143 response = await self.privateFuturesPostSettleOrders(orderRequest)

Callers 2

close_positionMethod · 0.95

Tested by

no test coverage detected