MCPcopy Create free account
hub / github.com/ccxt/ccxt / create_orders

Method create_orders

python/ccxt/ascendex.py:1795–1881  ·  view source on GitHub ↗

create a list of trade orders https://ascendex.github.io/ascendex-pro-api/#place-batch-orders https://ascendex.github.io/ascendex-futures-pro-api-v2/#place-batch-orders :param Array orders: list of orders to create, each object should contain the parameters require

(self, orders: List[OrderRequest], params={})

Source from the content-addressed store, hash-verified

1793 return self.parse_order(order, market)
1794
1795 def create_orders(self, orders: List[OrderRequest], params={}):
1796 """
1797 create a list of trade orders
1798
1799 https://ascendex.github.io/ascendex-pro-api/#place-batch-orders
1800 https://ascendex.github.io/ascendex-futures-pro-api-v2/#place-batch-orders
1801
1802 :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
1803 :param dict [params]: extra parameters specific to the exchange API endpoint
1804 :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1805 :param bool [params.postOnly]: True or False
1806 :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1807 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1808 """
1809 self.load_markets()
1810 self.load_accounts()
1811 ordersRequests = []
1812 symbol = None
1813 marginMode = None
1814 for i in range(0, len(orders)):
1815 rawOrder = orders[i]
1816 marketId = self.safe_string(rawOrder, 'symbol')
1817 if symbol is None:
1818 symbol = marketId
1819 else:
1820 if symbol != marketId:
1821 raise BadRequest(self.id + ' createOrders() requires all orders to have the same symbol')
1822 type = self.safe_string(rawOrder, 'type')
1823 side = self.safe_string(rawOrder, 'side')
1824 amount = self.safe_number(rawOrder, 'amount')
1825 price = self.safe_number(rawOrder, 'price')
1826 orderParams = self.safe_dict(rawOrder, 'params', {})
1827 marginResult = self.handle_margin_mode_and_params('createOrders', orderParams)
1828 currentMarginMode = marginResult[0]
1829 if currentMarginMode is not None:
1830 if marginMode is None:
1831 marginMode = currentMarginMode
1832 else:
1833 if marginMode != currentMarginMode:
1834 raise BadRequest(self.id + ' createOrders() requires all orders to have the same margin mode(isolated or cross)')
1835 orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
1836 ordersRequests.append(orderRequest)
1837 market = self.market(symbol)
1838 accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1839 accountCategory = self.safe_string(accountsByType, market['type'], 'cash')
1840 if marginMode is not None:
1841 accountCategory = 'margin'
1842 account = self.safe_dict(self.accounts, 0, {})
1843 accountGroup = self.safe_string(account, 'id')
1844 request = {}
1845 response = None
1846 if market['swap']:
1847 raise NotSupported(self.id + ' createOrders() is not currently supported for swap markets on ascendex')
1848 # request['account-group'] = accountGroup
1849 # request['category'] = accountCategory
1850 # request['orders'] = ordersRequests
1851 # response = self.v2PrivateAccountGroupPostFuturesOrderBatch(request)
1852 else:

Callers

nothing calls this directly

Calls 15

create_order_requestMethod · 0.95
BadRequestClass · 0.90
NotSupportedClass · 0.90
safe_stringMethod · 0.80
safe_numberMethod · 0.80
safe_dictMethod · 0.80
safe_listMethod · 0.80
parse_ordersMethod · 0.80
rangeFunction · 0.50
load_marketsMethod · 0.45
load_accountsMethod · 0.45

Tested by

no test coverage detected