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

Method create_order

python/ccxt/cex.py:1206–1298  ·  view source on GitHub ↗

create a trade order https://trade.cex.io/docs/#rest-private-api-calls-new-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 muc

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

Source from the content-addressed store, hash-verified

1204 }, market)
1205
1206 def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1207 """
1208 create a trade order
1209
1210 https://trade.cex.io/docs/#rest-private-api-calls-new-order
1211
1212 :param str symbol: unified symbol of the market to create an order in
1213 :param str type: 'market' or 'limit'
1214 :param str side: 'buy' or 'sell'
1215 :param float amount: how much of currency you want to trade in units of base currency
1216 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1217 :param dict [params]: extra parameters specific to the exchange API endpoint
1218 :param str [params.accountId]: account-id to use(default is empty string)
1219 :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1220 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1221 """
1222 accountId = None
1223 accountId, params = self.handle_option_and_params(params, 'createOrder', 'accountId')
1224 if accountId is None:
1225 raise ArgumentsRequired(self.id + ' createOrder() : API trading is now allowed from main account, set params["accountId"] or .options["createOrder"]["accountId"] to the name of your sub-account')
1226 self.load_markets()
1227 market = self.market(symbol)
1228 request = {
1229 'clientOrderId': self.uuid(),
1230 'currency1': market['baseId'],
1231 'currency2': market['quoteId'],
1232 'accountId': accountId,
1233 'orderType': self.capitalize(type.lower()),
1234 'side': side.upper(),
1235 'timestamp': self.milliseconds(),
1236 'amountCcy1': self.amount_to_precision(symbol, amount),
1237 }
1238 timeInForce = None
1239 timeInForce, params = self.handle_option_and_params(params, 'createOrder', 'timeInForce', 'GTC')
1240 if type == 'limit':
1241 request['price'] = self.price_to_precision(symbol, price)
1242 request['timeInForce'] = timeInForce
1243 triggerPrice = None
1244 triggerPrice, params = self.handle_param_string(params, 'triggerPrice')
1245 if triggerPrice is not None:
1246 request['type'] = 'Stop Limit'
1247 request['stopPrice'] = triggerPrice
1248 response = self.privatePostDoMyNewOrder(self.extend(request, params))
1249 #
1250 # on success
1251 #
1252 # {
1253 # "ok": "ok",
1254 # "data": {
1255 # "messageType": "executionReport",
1256 # "clientId": "up132245425",
1257 # "orderId": "1318485",
1258 # "clientOrderId": "b5b6cd40-154c-4c1c-bd51-4a442f3d50b9",
1259 # "accountId": "sub1",
1260 # "status": "FILLED",
1261 # "currency1": "LTC",
1262 # "currency2": "USDT",
1263 # "side": "BUY",

Callers

nothing calls this directly

Calls 14

parse_orderMethod · 0.95
ArgumentsRequiredClass · 0.90
handle_param_stringMethod · 0.80
safe_dictMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
uuidMethod · 0.45
capitalizeMethod · 0.45
millisecondsMethod · 0.45
amount_to_precisionMethod · 0.45

Tested by

no test coverage detected