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

Method create_order

python/ccxt/async_support/apex.py:1277–1372  ·  view source on GitHub ↗

create a trade order https://api-docs.omni.apex.exchange/#privateapi-v3-for-omni-post-creating-orders :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

(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})

Source from the content-addressed store, hash-verified

1275 return self.options['accountId']
1276
1277 async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1278 """
1279 create a trade order
1280
1281 https://api-docs.omni.apex.exchange/#privateapi-v3-for-omni-post-creating-orders
1282
1283 :param str symbol: unified symbol of the market to create an order in
1284 :param str type: 'market' or 'limit'
1285 :param str side: 'buy' or 'sell'
1286 :param float amount: how much of currency you want to trade in units of base currency
1287 :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1288 :param dict [params]: extra parameters specific to the exchange API endpoint
1289 :param float [params.triggerPrice]: The price a trigger order is triggered at
1290 :param float [params.stopLossPrice]: The price a stop loss order is triggered at
1291 :param float [params.takeProfitPrice]: The price a take profit order is triggered at
1292 :param str [params.timeInForce]: "GTC", "IOC", or "POST_ONLY"
1293 :param bool [params.postOnly]: True or False
1294 :param bool [params.reduceOnly]: Ensures that the executed order does not flip the opened position.
1295 :param str [params.clientOrderId]: a unique id for the order
1296 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1297 """
1298 await self.load_markets()
1299 market = self.market(symbol)
1300 orderType = type.upper()
1301 orderSide = side.upper()
1302 orderSize = self.amount_to_precision(symbol, amount)
1303 orderPrice = '0'
1304 if price is not None:
1305 orderPrice = self.price_to_precision(symbol, price)
1306 fees = self.safe_dict(self.fees, 'swap', {})
1307 taker = self.safe_string(fees, 'taker', '0.0005')
1308 maker = self.safe_string(fees, 'maker', '0.0002')
1309 limitFee = self.decimal_to_precision(Precise.string_add(Precise.string_mul(Precise.string_mul(orderPrice, orderSize), taker), self.number_to_string(market['precision']['price'])), TRUNCATE, market['precision']['price'], self.precisionMode, self.paddingMode)
1310 timeNow = self.milliseconds()
1311 triggerPrice = self.safe_string(params, 'triggerPrice')
1312 stopLossPrice = self.safe_string(params, 'stopLossPrice')
1313 takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
1314 if stopLossPrice is not None:
1315 orderType = 'STOP_MARKET' if (orderType == 'MARKET') else 'STOP_LIMIT'
1316 triggerPrice = stopLossPrice
1317 elif takeProfitPrice is not None:
1318 orderType = 'TAKE_PROFIT_MARKET' if (orderType == 'MARKET') else 'TAKE_PROFIT_LIMIT'
1319 triggerPrice = takeProfitPrice
1320 isMarket = orderType == 'MARKET'
1321 if isMarket and (price is None):
1322 raise ArgumentsRequired(self.id + ' createOrder() requires a price argument for market orders')
1323 timeInForce = self.safe_string_upper(params, 'timeInForce')
1324 postOnly = self.is_post_only(isMarket, None, params)
1325 if timeInForce is None:
1326 timeInForce = 'GOOD_TIL_CANCEL'
1327 if not isMarket:
1328 if postOnly:
1329 timeInForce = 'POST_ONLY'
1330 elif timeInForce == 'ioc':
1331 timeInForce = 'IMMEDIATE_OR_CANCEL'
1332 params = self.omit(params, 'timeInForce')
1333 params = self.omit(params, 'postOnly')
1334 clientOrderId = self.safe_string_n(params, ['clientId', 'clientOrderId', 'client_order_id'])

Callers

nothing calls this directly

Calls 15

get_account_idMethod · 0.95
get_seedsMethod · 0.95
parse_orderMethod · 0.95
ArgumentsRequiredClass · 0.90
safe_dictMethod · 0.80
safe_stringMethod · 0.80
string_addMethod · 0.80
string_mulMethod · 0.80
safe_string_upperMethod · 0.80
is_post_onlyMethod · 0.80
safe_string_nMethod · 0.80

Tested by

no test coverage detected