create a trade order :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 of currency you want to trade in units of base currency :par
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 826 | return self.safe_integer(response, 'nonce') |
| 827 | |
| 828 | def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 829 | """ |
| 830 | create a trade order |
| 831 | :param str symbol: unified symbol of the market to create an order in |
| 832 | :param str type: 'market' or 'limit' |
| 833 | :param str side: 'buy' or 'sell' |
| 834 | :param float amount: how much of currency you want to trade in units of base currency |
| 835 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 836 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 837 | :param str [params.timeInForce]: 'GTT' or 'IOC', default is 'GTT' |
| 838 | :param int [params.clientOrderId]: client order id, should be unique for each order, default is a random number |
| 839 | :param str [params.triggerPrice]: trigger price for stop loss or take profit orders, in units of the quote currency |
| 840 | :param boolean [params.reduceOnly]: whether the order is reduce only, default False |
| 841 | :param int [params.nonce]: nonce for the account |
| 842 | :param int [params.apiKeyIndex]: apiKeyIndex |
| 843 | :param int [params.accountIndex]: accountIndex |
| 844 | :param int [params.orderExpiry]: orderExpiry |
| 845 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 846 | """ |
| 847 | self.load_markets() |
| 848 | accountIndex = None |
| 849 | accountIndex, params = self.handle_account_index(params, 'createOrder', 'accountIndex', 'account_index') |
| 850 | params['accountIndex'] = accountIndex |
| 851 | market = self.market(symbol) |
| 852 | groupingType = None |
| 853 | groupingType, params = self.handle_option_and_params(params, 'createOrder', 'groupingType', 3) # default GROUPING_TYPE_ONE_TRIGGERS_A_ONE_CANCELS_THE_OTHER |
| 854 | orderRequests = self.create_order_request(symbol, type, side, amount, price, params) |
| 855 | # for php |
| 856 | totalOrderRequests = len(orderRequests) |
| 857 | apiKeyIndex = None |
| 858 | order = None |
| 859 | if totalOrderRequests > 0: |
| 860 | order = orderRequests[0] |
| 861 | apiKeyIndex = order['api_key_index'] |
| 862 | strAccountIndex = self.number_to_string(accountIndex) |
| 863 | strApiKeyIndex = self.number_to_string(apiKeyIndex) |
| 864 | signer = self.load_account(self.options['chainId'], self.get_lighter_private_key(strAccountIndex, strApiKeyIndex), strApiKeyIndex, strAccountIndex, params) |
| 865 | # the nonce could be updated |
| 866 | if self.safe_integer(order, 'nonce') is None: |
| 867 | order['nonce'] = self.fetch_nonce(accountIndex, apiKeyIndex) |
| 868 | txType = None |
| 869 | txInfo: dict |
| 870 | if totalOrderRequests < 2: |
| 871 | txType, txInfo = self.lighter_sign_create_order(signer, order) |
| 872 | else: |
| 873 | signingPayload = { |
| 874 | 'grouping_type': groupingType, |
| 875 | 'orders': orderRequests, |
| 876 | 'nonce': order['nonce'], |
| 877 | 'api_key_index': apiKeyIndex, |
| 878 | 'account_index': accountIndex, |
| 879 | } |
| 880 | if self.safe_bool(self.options, 'builderFee', True): |
| 881 | signingPayload['integrator_account_index'] = order['integrator_account_index'] |
| 882 | signingPayload['integrator_taker_fee'] = order['integrator_taker_fee'] |
| 883 | signingPayload['integrator_maker_fee'] = order['integrator_maker_fee'] |
| 884 | txType, txInfo = self.lighter_sign_create_grouped_orders(signer, signingPayload) |
| 885 | request = { |
nothing calls this directly
no test coverage detected