create a trade order https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order # spot, margin https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order # coin-m swap https://huobiapi.github.io/docs/coin_margined_sw
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 5172 | return self.extend(request, params) |
| 5173 | |
| 5174 | async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> Order: |
| 5175 | """ |
| 5176 | create a trade order |
| 5177 | |
| 5178 | https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order # spot, margin |
| 5179 | https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order # coin-m swap |
| 5180 | https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order # coin-m swap trigger |
| 5181 | https://www.htx.com/en-us/opend/newApiPages/?id=8cb89359-77b5-11ed-9966-19588768fe7 # usdt-m swap cross and isolated |
| 5182 | https://www.htx.com/en-us/opend/newApiPages/?id=8cb89359-77b5-11ed-9966-19b933812c9 # usdt-m swap cross and isolated trigger and trailing orders |
| 5183 | https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-set-a-take-profit-and-stop-loss-order-for-an-existing-position |
| 5184 | https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-set-a-take-profit-and-stop-loss-order-for-an-existing-position |
| 5185 | https://huobiapi.github.io/docs/dm/v1/en/#place-an-order # coin-m futures |
| 5186 | https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order # coin-m futures contract trigger |
| 5187 | |
| 5188 | :param str symbol: unified symbol of the market to create an order in |
| 5189 | :param str type: 'market' or 'limit' |
| 5190 | :param str side: 'buy' or 'sell' |
| 5191 | :param float amount: how much you want to trade in units of the base currency |
| 5192 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 5193 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 5194 | :param float [params.triggerPrice]: the price a trigger order is triggered at |
| 5195 | :param str [params.triggerType]: *contract trigger orders only* ge: greater than or equal to, le: less than or equal to |
| 5196 | :param float [params.stopLossPrice]: *contract only* the price a stop-loss order is triggered at |
| 5197 | :param float [params.takeProfitPrice]: *contract only* the price a take-profit order is triggered at |
| 5198 | :param str [params.operator]: *spot and margin only* gte or lte, trigger price condition |
| 5199 | :param str [params.offset]: *contract only* 'both'(linear only), 'open', or 'close', required in hedge mode and for inverse markets |
| 5200 | :param bool [params.postOnly]: *contract only* True or False |
| 5201 | :param int [params.leverRate]: *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement |
| 5202 | :param str [params.timeInForce]: supports 'IOC' and 'FOK' |
| 5203 | :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount |
| 5204 | :param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price |
| 5205 | :param float [params.trailingTriggerPrice]: *contract only* the price to trigger a trailing order, default uses the price argument |
| 5206 | :param bool [params.hedged]: *contract only* True for hedged mode, False for one way mode, default is False |
| 5207 | :param str [params.marginMode]: linear swap supports 'cross' and 'isolated', 'cross' is the default |
| 5208 | :param str [params.position_side]: linear swap supports 'long', 'short' and 'both', 'both' is the default |
| 5209 | :param dict [params.takeProfit]: *takeProfit object in params, linear swap only* containing the triggerPrice at which the attached take profit order will be triggered |
| 5210 | :param float [params.takeProfit.triggerPrice]: take profit trigger price |
| 5211 | :param float [params.takeProfit.price]: take profit price for take profit orders |
| 5212 | :param str [params.takeProfit.type]: market is the default, limit, optimal_5, optimal_10, optimal_20 |
| 5213 | :param dict [params.stopLoss]: *stopLoss object in params, linear swap only* containing the triggerPrice at which the attached stop loss order will be triggered |
| 5214 | :param float [params.stopLoss.triggerPrice]: stop loss trigger price |
| 5215 | :param float [params.stopLoss.price]: stop loss price for stop loss orders |
| 5216 | :param str [params.stopLoss.type]: market is the default, limit, optimal_5, optimal_10, optimal_20 |
| 5217 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 5218 | """ |
| 5219 | await self.load_markets() |
| 5220 | market = self.market(symbol) |
| 5221 | triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'trigger_price']) |
| 5222 | stopLossTriggerPrice = self.safe_number_2(params, 'stopLossPrice', 'sl_trigger_price') |
| 5223 | takeProfitTriggerPrice = self.safe_number_2(params, 'takeProfitPrice', 'tp_trigger_price') |
| 5224 | trailingPercent = self.safe_number(params, 'trailingPercent') |
| 5225 | isTrailingPercentOrder = trailingPercent is not None |
| 5226 | isTrigger = triggerPrice is not None |
| 5227 | isStopLossTriggerOrder = stopLossTriggerPrice is not None |
| 5228 | isTakeProfitTriggerOrder = takeProfitTriggerPrice is not None |
| 5229 | response = None |
| 5230 | if market['spot']: |
| 5231 | if isTrailingPercentOrder: |
no test coverage detected