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

Method create_spot_order

python/ccxt/hashkey.py:2432–2548  ·  view source on GitHub ↗

create a trade order on spot market https://hashkeyglobal-apidoc.readme.io/reference/test-new-order https://hashkeyglobal-apidoc.readme.io/reference/create-order :param str symbol: unified symbol of the market to create an order in :param str type: 'market'

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

Source from the content-addressed store, hash-verified

2430 return self.create_order(symbol, 'market', 'buy', cost, None, self.extend(req, params))
2431
2432 def create_spot_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> Order:
2433 """
2434 create a trade order on spot market
2435
2436 https://hashkeyglobal-apidoc.readme.io/reference/test-new-order
2437 https://hashkeyglobal-apidoc.readme.io/reference/create-order
2438
2439 :param str symbol: unified symbol of the market to create an order in
2440 :param str type: 'market' or 'limit' or 'LIMIT_MAKER'
2441 :param str side: 'buy' or 'sell'
2442 :param float amount: how much of you want to trade in units of the base currency
2443 :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
2444 :param dict [params]: extra parameters specific to the exchange API endpoint
2445 :param float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount
2446 :param bool [params.test]: whether to use the test endpoint or not, default is False
2447 :param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
2448 :param str [params.timeInForce]: 'GTC', 'IOC', or 'PO'
2449 :param str [params.clientOrderId]: a unique id for the order
2450 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
2451 """
2452 triggerPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
2453 if triggerPrice is not None:
2454 raise NotSupported(self.id + ' trigger orders are not supported for spot markets')
2455 self.load_markets()
2456 market = self.market(symbol)
2457 isMarketBuy = (type == 'market') and (side == 'buy')
2458 cost = self.safe_string(params, 'cost')
2459 if (not isMarketBuy) and (cost is not None):
2460 raise NotSupported(self.id + ' createOrder() supports cost parameter for spot market buy orders only')
2461 request = self.create_spot_order_request(symbol, type, side, amount, price, params)
2462 response = {}
2463 test = self.safe_bool(params, 'test')
2464 if test:
2465 params = self.omit(params, 'test')
2466 response = self.privatePostApiV1SpotOrderTest(request)
2467 elif isMarketBuy and (cost is None):
2468 response = self.privatePostApiV11SpotOrder(request) # the endpoint for market buy orders by amount
2469 #
2470 # {
2471 # "accountId": "1732885739589466112",
2472 # "symbol": "ETHUSDT",
2473 # "symbolName": "ETHUSDT",
2474 # "clientOrderId": "1722005792096557",
2475 # "orderId": "1738705036219839744",
2476 # "transactTime": "1722005792106",
2477 # "price": "0",
2478 # "origQty": "0.006",
2479 # "executedQty": "0.0059",
2480 # "status": "FILLED",
2481 # "timeInForce": "IOC",
2482 # "type": "MARKET",
2483 # "side": "BUY",
2484 # "reqAmount": "0",
2485 # "concentration": ""
2486 # }
2487 #
2488 else:
2489 response = self.privatePostApiV1SpotOrder(request) # the endpoint for market buy orders by cost and other orders

Callers 1

create_orderMethod · 0.95

Calls 12

parse_orderMethod · 0.95
NotSupportedClass · 0.90
safe_string_2Method · 0.80
safe_stringMethod · 0.80
safe_boolMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
omitMethod · 0.45

Tested by

no test coverage detected