create a trade order https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#place-order https://phemex-docs.github.io/#place-order-http-put-prefered-3 :param str symbol: unified symbol of the market to create an order in :param
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 2553 | return self.parse_spot_order(order, market) |
| 2554 | |
| 2555 | def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 2556 | """ |
| 2557 | create a trade order |
| 2558 | |
| 2559 | https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#place-order |
| 2560 | https://phemex-docs.github.io/#place-order-http-put-prefered-3 |
| 2561 | |
| 2562 | :param str symbol: unified symbol of the market to create an order in |
| 2563 | :param str type: 'market' or 'limit' |
| 2564 | :param str side: 'buy' or 'sell' |
| 2565 | :param float amount: how much of currency you want to trade in units of base currency |
| 2566 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 2567 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 2568 | :param float [params.trigger]: trigger price for conditional orders |
| 2569 | :param dict [params.takeProfit]: *swap only* *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only) |
| 2570 | :param float [params.takeProfit.triggerPrice]: take profit trigger price |
| 2571 | :param dict [params.stopLoss]: *swap only* *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only) |
| 2572 | :param float [params.stopLoss.triggerPrice]: stop loss trigger price |
| 2573 | :param str [params.posSide]: *swap only* "Merged" for one way mode, "Long" for buy side of hedged mode, "Short" for sell side of hedged mode |
| 2574 | :param bool [params.hedged]: *swap only* True for hedged mode, False for one way mode, default is False |
| 2575 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 2576 | """ |
| 2577 | self.load_markets() |
| 2578 | market = self.market(symbol) |
| 2579 | requestSide = self.capitalize(side) |
| 2580 | type = self.capitalize(type) |
| 2581 | request = { |
| 2582 | # common |
| 2583 | 'symbol': market['id'], |
| 2584 | 'side': requestSide, # Sell, Buy |
| 2585 | 'ordType': type, # Market, Limit, Stop, StopLimit, MarketIfTouched, LimitIfTouched(additionally for contract-markets: MarketAsLimit, StopAsLimit, MarketIfTouchedAsLimit) |
| 2586 | # 'stopPxEp': self.to_ep(stopPx, market), # for conditional orders |
| 2587 | # 'priceEp': self.to_ep(price, market), # required for limit orders |
| 2588 | # 'timeInForce': 'GoodTillCancel', # GoodTillCancel, PostOnly, ImmediateOrCancel, FillOrKill |
| 2589 | # ---------------------------------------------------------------- |
| 2590 | # spot |
| 2591 | # 'qtyType': 'ByBase', # ByBase, ByQuote |
| 2592 | # 'quoteQtyEv': self.to_ep(cost, market), |
| 2593 | # 'baseQtyEv': self.to_ev(amount, market), |
| 2594 | # 'trigger': 'ByLastPrice', # required for conditional orders |
| 2595 | # ---------------------------------------------------------------- |
| 2596 | # swap |
| 2597 | # 'clOrdID': self.uuid(), # max length 40 |
| 2598 | # 'orderQty': self.amount_to_precision(amount, symbol), |
| 2599 | # 'reduceOnly': False, |
| 2600 | # 'closeOnTrigger': False, # implicit reduceOnly and cancel other orders in the same direction |
| 2601 | # 'takeProfitEp': self.to_ep(takeProfit, market), |
| 2602 | # 'stopLossEp': self.to_ep(stopLossEp, market), |
| 2603 | # 'triggerType': 'ByMarkPrice', # ByMarkPrice, ByLastPrice |
| 2604 | # 'pegOffsetValueEp': integer, # Trailing offset from current price. Negative value when position is long, positive when position is short |
| 2605 | # 'pegPriceType': 'TrailingStopPeg', # TrailingTakeProfitPeg |
| 2606 | # 'text': 'comment', |
| 2607 | # 'posSide': Position direction - "Merged" for oneway mode , "Long" / "Short" for hedge mode |
| 2608 | } |
| 2609 | clientOrderId = self.safe_string_2(params, 'clOrdID', 'clientOrderId') |
| 2610 | stopLoss = self.safe_value(params, 'stopLoss') |
| 2611 | takeProfit = self.safe_value(params, 'takeProfit') |
| 2612 | hasStopLoss = (stopLoss is not None) |
nothing calls this directly
no test coverage detected