create a trade order https://doc.xt.com/#orderorderPost https://doc.xt.com/#futures_ordercreate https://doc.xt.com/#futures_entrustcreatePlan https://doc.xt.com/#futures_entrustcreateProfit :param str symbol: unified symbol of the market to create a
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 2350 | return await self.create_order(symbol, 'market', 'buy', cost, 1, params) |
| 2351 | |
| 2352 | async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 2353 | """ |
| 2354 | create a trade order |
| 2355 | |
| 2356 | https://doc.xt.com/#orderorderPost |
| 2357 | https://doc.xt.com/#futures_ordercreate |
| 2358 | https://doc.xt.com/#futures_entrustcreatePlan |
| 2359 | https://doc.xt.com/#futures_entrustcreateProfit |
| 2360 | |
| 2361 | :param str symbol: unified symbol of the market to create an order in |
| 2362 | :param str type: 'market' or 'limit' |
| 2363 | :param str side: 'buy' or 'sell' |
| 2364 | :param float amount: how much you want to trade in units of the base currency |
| 2365 | :param float [price]: the price to fulfill the order, in units of the quote currency, can be ignored in market orders |
| 2366 | :param dict params: extra parameters specific to the xt api endpoint |
| 2367 | :param str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'GTX' |
| 2368 | :param str [params.entrustType]: 'TAKE_PROFIT', 'STOP', 'TAKE_PROFIT_MARKET', 'STOP_MARKET', 'TRAILING_STOP_MARKET', required if stopPrice is defined, currently isn't functioning on xt's side |
| 2369 | :param str [params.triggerPriceType]: 'INDEX_PRICE', 'MARK_PRICE', 'LATEST_PRICE', required if stopPrice is defined |
| 2370 | :param float [params.triggerPrice]: price to trigger a stop order |
| 2371 | :param float [params.stopPrice]: alias for triggerPrice |
| 2372 | :param float [params.stopLoss]: price to set a stop-loss on an open position |
| 2373 | :param float [params.takeProfit]: price to set a take-profit on an open position |
| 2374 | :returns dict: an `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>` |
| 2375 | """ |
| 2376 | await self.load_markets() |
| 2377 | market = self.market(symbol) |
| 2378 | symbol = market['symbol'] |
| 2379 | if market['spot']: |
| 2380 | return await self.create_spot_order(symbol, type, side, amount, price, params) |
| 2381 | else: |
| 2382 | return await self.create_contract_order(symbol, type, side, amount, price, params) |
| 2383 | |
| 2384 | async def create_spot_order(self, symbol: str, type, side, amount, price=None, params={}): |
| 2385 | await self.load_markets() |