Create an order with the specified characteristics https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_create :param str symbol: unified symbol of the market to create an order in :param str type: 'market', 'limit', 'stop_market', 'stop_limit
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 889 | return self.parse_orders(data) |
| 890 | |
| 891 | def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> Order: |
| 892 | """ |
| 893 | Create an order with the specified characteristics |
| 894 | |
| 895 | https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_create |
| 896 | |
| 897 | :param str symbol: unified symbol of the market to create an order in |
| 898 | :param str type: 'market', 'limit', 'stop_market', 'stop_limit', 'instant' |
| 899 | :param str side: 'buy' or 'sell' |
| 900 | :param float amount: how much you want to trade in units of the base currency |
| 901 | :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders |
| 902 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 903 | :param str [params.timeInForce]: "GTC", "FOK", "IOC", "PO" |
| 904 | :param float [params.triggerPrice]: The time in force for the order. One of GTC, FOK, IOC, PO. See .features or foxbit's doc to see more details. |
| 905 | :param bool [params.postOnly]: True or False whether the order is post-only |
| 906 | :param str [params.clientOrderId]: a unique identifier for the order |
| 907 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 908 | """ |
| 909 | self.load_markets() |
| 910 | market = self.market(symbol) |
| 911 | type = type.upper() |
| 912 | if type != 'LIMIT' and type != 'MARKET' and type != 'STOP_MARKET' and type != 'STOP_LIMIT' and type != 'INSTANT': |
| 913 | raise InvalidOrder('Invalid order type: ' + type + '. Must be one of: limit, market, stop_market, stop_limit, instant.') |
| 914 | timeInForce = self.safe_string_upper(params, 'timeInForce') |
| 915 | postOnly = self.safe_bool(params, 'postOnly', False) |
| 916 | triggerPrice = self.safe_number(params, 'triggerPrice') |
| 917 | request = { |
| 918 | 'market_symbol': market['id'], |
| 919 | 'side': side.upper(), |
| 920 | 'type': type, |
| 921 | } |
| 922 | if type == 'STOP_MARKET' or type == 'STOP_LIMIT': |
| 923 | if triggerPrice is None: |
| 924 | raise InvalidOrder('Invalid order type: ' + type + '. Must have triggerPrice.') |
| 925 | if timeInForce is not None: |
| 926 | if timeInForce == 'PO': |
| 927 | request['post_only'] = True |
| 928 | else: |
| 929 | request['time_in_force'] = timeInForce |
| 930 | if postOnly: |
| 931 | request['post_only'] = True |
| 932 | if triggerPrice is not None: |
| 933 | request['stop_price'] = self.price_to_precision(symbol, triggerPrice) |
| 934 | if type == 'INSTANT': |
| 935 | request['amount'] = self.price_to_precision(symbol, amount) |
| 936 | else: |
| 937 | request['quantity'] = self.amount_to_precision(symbol, amount) |
| 938 | if type == 'LIMIT' or type == 'STOP_LIMIT': |
| 939 | request['price'] = self.price_to_precision(symbol, price) |
| 940 | clientOrderId = self.safe_string(params, 'clientOrderId') |
| 941 | if clientOrderId is not None: |
| 942 | request['client_order_id'] = clientOrderId |
| 943 | params = self.omit(params, ['timeInForce', 'postOnly', 'triggerPrice', 'clientOrderId']) |
| 944 | response = self.v3PrivatePostOrders(self.extend(request, params)) |
| 945 | # { |
| 946 | # "id": 1234567890, |
| 947 | # "sn": "OKMAKSDHRVVREK", |
| 948 | # "client_order_id": "451637946501" |
nothing calls this directly
no test coverage detected