create a trade order https://api-docs.grvt.io/trading_api/#create-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 curr
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 1874 | return self.parse_transaction(result, currency) |
| 1875 | |
| 1876 | def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 1877 | """ |
| 1878 | create a trade order |
| 1879 | |
| 1880 | https://api-docs.grvt.io/trading_api/#create-order |
| 1881 | |
| 1882 | :param str symbol: unified symbol of the market to create an order in |
| 1883 | :param str type: 'market' or 'limit' |
| 1884 | :param str side: 'buy' or 'sell' |
| 1885 | :param float amount: how much of currency you want to trade in units of base currency |
| 1886 | :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders |
| 1887 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1888 | :param float [params.triggerPrice]: The price a trigger order is triggered at |
| 1889 | :param float [params.stopLossPrice]: The price a stop loss order is triggered at |
| 1890 | :param float [params.takeProfitPrice]: The price a take profit order is triggered at |
| 1891 | :param str [params.timeInForce]: "GTC", "IOC", or "POST_ONLY" |
| 1892 | :param bool [params.postOnly]: True or False |
| 1893 | :param bool [params.reduceOnly]: Ensures that the executed order does not flip the opened position. |
| 1894 | :param str [params.clientOrderId]: a unique id for the order |
| 1895 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 1896 | """ |
| 1897 | self.load_markets_and_sign_in() |
| 1898 | market = self.market(symbol) |
| 1899 | orderLeg = { |
| 1900 | 'instrument': market['id'], |
| 1901 | 'size': self.amount_to_precision(symbol, amount), |
| 1902 | } |
| 1903 | if price is not None: |
| 1904 | orderLeg['limit_price'] = self.price_to_precision(symbol, price) |
| 1905 | else: |
| 1906 | orderLeg['limit_price'] = None |
| 1907 | if side == 'sell': |
| 1908 | orderLeg['is_buying_asset'] = False |
| 1909 | elif side == 'buy': |
| 1910 | orderLeg['is_buying_asset'] = True |
| 1911 | else: |
| 1912 | raise InvalidOrder(self.id + ' createOrder(): order side must be either "buy" or "sell"') |
| 1913 | clientOrderId = self.safe_string(params, 'clientOrderId') |
| 1914 | if clientOrderId is None: |
| 1915 | clientOrderId = str(self.nonce()) + '000' + str(self.request_id()) |
| 1916 | params = self.omit(params, ['clientOrderId']) |
| 1917 | isMarketOrder = (type == 'market') |
| 1918 | subAccountId = self.get_sub_account_id(params) |
| 1919 | isReduceOnly = self.safe_bool(params, 'reduceOnly', False) |
| 1920 | orderRequest = { |
| 1921 | 'sub_account_id': subAccountId, |
| 1922 | 'time_in_force': None, |
| 1923 | 'legs': [orderLeg], |
| 1924 | 'signature': self.default_signature(), |
| 1925 | 'metadata': { |
| 1926 | 'client_order_id': clientOrderId, |
| 1927 | }, |
| 1928 | 'is_market': isMarketOrder, |
| 1929 | 'post_only': False, |
| 1930 | 'reduce_only': isReduceOnly, |
| 1931 | # 'order_id': null, |
| 1932 | # 'state': null, |
| 1933 | } |
nothing calls this directly
no test coverage detected