create a trade order https://www.bitmex.com/api/explorer/#not /Order/Order_new :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or 'limit' :param str side: 'buy' or 'sell' :param float amount: how much
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 2010 | return self.parse_trades(response, market, since, limit) |
| 2011 | |
| 2012 | async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 2013 | """ |
| 2014 | create a trade order |
| 2015 | |
| 2016 | https://www.bitmex.com/api/explorer/#not /Order/Order_new |
| 2017 | |
| 2018 | :param str symbol: unified symbol of the market to create an order in |
| 2019 | :param str type: 'market' or 'limit' |
| 2020 | :param str side: 'buy' or 'sell' |
| 2021 | :param float amount: how much of currency you want to trade in units of base currency |
| 2022 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 2023 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 2024 | :param dict [params.triggerPrice]: the price at which a trigger order is triggered at |
| 2025 | :param dict [params.triggerDirection]: the direction whenever the trigger happens with relation to price - 'ascending' or 'descending' |
| 2026 | :param float [params.trailingAmount]: the quote amount to trail away from the current market price |
| 2027 | :returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>` |
| 2028 | """ |
| 2029 | await self.load_markets() |
| 2030 | market = self.market(symbol) |
| 2031 | orderType = self.capitalize(type) |
| 2032 | capitalizeOrderType = orderType |
| 2033 | reduceOnly = self.safe_value(params, 'reduceOnly') |
| 2034 | if reduceOnly is not None: |
| 2035 | if (not market['swap']) and (not market['future']): |
| 2036 | raise InvalidOrder(self.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap and future markets only') |
| 2037 | postOnly = self.safe_bool(params, 'postOnly') |
| 2038 | params = self.omit(params, ['reduceOnly', 'postOnly']) |
| 2039 | brokerId = self.safe_string(self.options, 'brokerId', 'CCXT') |
| 2040 | qty = self.parse_to_int(self.amount_to_precision(symbol, amount)) |
| 2041 | request = { |
| 2042 | 'symbol': market['id'], |
| 2043 | 'side': self.capitalize(side), |
| 2044 | 'orderQty': qty, # lot size multiplied by the number of contracts |
| 2045 | 'ordType': capitalizeOrderType, |
| 2046 | 'text': brokerId, |
| 2047 | } |
| 2048 | execInstructions = [] |
| 2049 | if reduceOnly is True: |
| 2050 | execInstructions.append('ReduceOnly') |
| 2051 | if postOnly is True: |
| 2052 | execInstructions.append('ParticipateDoNotInitiate') |
| 2053 | execInstLength = len(execInstructions) |
| 2054 | if execInstLength > 0: |
| 2055 | request['execInst'] = ','.join(execInstructions) |
| 2056 | # support for unified trigger format |
| 2057 | triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPx', 'stopPrice']) |
| 2058 | trailingAmount = self.safe_string_2(params, 'trailingAmount', 'pegOffsetValue') |
| 2059 | isTriggerOrder = triggerPrice is not None |
| 2060 | isTrailingAmountOrder = trailingAmount is not None |
| 2061 | if isTriggerOrder or isTrailingAmountOrder: |
| 2062 | triggerDirection = self.safe_string(params, 'triggerDirection') |
| 2063 | triggerAbove = ((triggerDirection == 'ascending') or (triggerDirection == 'above')) |
| 2064 | if (type == 'limit') or (type == 'market'): |
| 2065 | self.check_required_argument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']) |
| 2066 | if type == 'limit': |
| 2067 | if side == 'buy': |
| 2068 | orderType = 'StopLimit' if triggerAbove else 'LimitIfTouched' |
| 2069 | else: |
nothing calls this directly
no test coverage detected