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