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

Method test_kucoin

python/ccxt/test/tests_async.py:1406–1447  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1404 return True
1405
1406 async def test_kucoin(self):
1407 exchange = self.init_offline_exchange('kucoin')
1408 exchange.options['uta'] = False # prevents fetching account mode inside createOrder
1409 req_headers = None
1410 spot_id = exchange.options['partner']['spot']['id']
1411 spot_key = exchange.options['partner']['spot']['key']
1412 assert spot_id == 'ccxt', 'kucoin - id: ' + spot_id + ' not in options'
1413 assert spot_key == '9e58cc35-5b5e-4133-92ec-166e3f077cb8', 'kucoin - key: ' + spot_key + ' not in options.'
1414 future_id = exchange.options['partner']['future']['id']
1415 future_key = exchange.options['partner']['future']['key']
1416 assert future_id == 'ccxtfutures', 'kucoin - id: ' + future_id + ' not in options.'
1417 assert future_key == '1b327198-f30c-4f14-a0ac-918871282f15', 'kucoin - key: ' + future_key + ' not in options.'
1418 try:
1419 await exchange.create_order('BTC/USDT', 'limit', 'buy', 1, 20000)
1420 except Exception as e:
1421 # we expect an error here, we're only interested in the headers
1422 req_headers = exchange.last_request_headers
1423 id = 'ccxt'
1424 assert req_headers['KC-API-PARTNER'] == id, 'kucoin - id: ' + id + ' not in headers for spot orders.'
1425 try:
1426 await exchange.create_order('BTC/USDT', 'limit', 'buy', 1, 20000, {
1427 'uta': True,
1428 })
1429 except Exception as e:
1430 req_headers = exchange.last_request_headers
1431 assert req_headers['KC-API-PARTNER'] == id, 'kucoin - id: ' + id + ' not in headers for spot uta orders.'
1432 id = 'ccxtfutures'
1433 try:
1434 await exchange.create_order('BTC/USDT:USDT', 'limit', 'buy', 1, 20000)
1435 except Exception as e:
1436 req_headers = exchange.last_request_headers
1437 assert req_headers['KC-API-PARTNER'] == id, 'kucoin - id: ' + id + ' not in headers for swap orders.'
1438 try:
1439 await exchange.create_order('BTC/USDT:USDT', 'limit', 'buy', 1, 20000, {
1440 'uta': True,
1441 })
1442 except Exception as e:
1443 req_headers = exchange.last_request_headers
1444 assert req_headers['KC-API-PARTNER'] == id, 'kucoin - id: ' + id + ' not in headers for swap uta orders.'
1445 if not is_sync():
1446 await close(exchange)
1447 return True
1448
1449 async def test_kucoinfutures(self):
1450 exchange = self.init_offline_exchange('kucoinfutures')

Callers 1

run_broker_id_testsMethod · 0.95

Calls 4

init_offline_exchangeMethod · 0.95
is_syncFunction · 0.90
closeFunction · 0.90
create_orderMethod · 0.45

Tested by

no test coverage detected