MCPcopy Index your code
hub / github.com/ccxt/ccxt / testKucoin

Method testKucoin

java/tests/src/main/java/tests/exchange/TestMain.java:2196–2258  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2194 }
2195
2196 public java.util.concurrent.CompletableFuture<Object> testKucoin()
2197 {
2198
2199 return java.util.concurrent.CompletableFuture.supplyAsync(() -> {
2200
2201 Exchange exchange = this.initOfflineExchange("kucoin");
2202 Helpers.addElementToObject(exchange.options, "uta", false); // prevents fetching account mode inside createOrder
2203 Object reqHeaders = null;
2204 Object spotId = Helpers.GetValue(Helpers.GetValue(Helpers.GetValue(exchange.options, "partner"), "spot"), "id");
2205 Object spotKey = Helpers.GetValue(Helpers.GetValue(Helpers.GetValue(exchange.options, "partner"), "spot"), "key");
2206 Assert(Helpers.isEqual(spotId, "ccxt"), Helpers.add(Helpers.add("kucoin - id: ", spotId), " not in options"));
2207 Assert(Helpers.isEqual(spotKey, "9e58cc35-5b5e-4133-92ec-166e3f077cb8"), Helpers.add(Helpers.add("kucoin - key: ", spotKey), " not in options."));
2208 Object futureId = Helpers.GetValue(Helpers.GetValue(Helpers.GetValue(exchange.options, "partner"), "future"), "id");
2209 Object futureKey = Helpers.GetValue(Helpers.GetValue(Helpers.GetValue(exchange.options, "partner"), "future"), "key");
2210 Assert(Helpers.isEqual(futureId, "ccxtfutures"), Helpers.add(Helpers.add("kucoin - id: ", futureId), " not in options."));
2211 Assert(Helpers.isEqual(futureKey, "1b327198-f30c-4f14-a0ac-918871282f15"), Helpers.add(Helpers.add("kucoin - key: ", futureKey), " not in options."));
2212 try
2213 {
2214 (exchange.createOrder("BTC/USDT", "limit", "buy", 1, 20000)).join();
2215 } catch(Exception e)
2216 {
2217 // we expect an error here, we're only interested in the headers
2218 reqHeaders = exchange.last_request_headers;
2219 }
2220 Object id = "ccxt";
2221 Assert(Helpers.isEqual(Helpers.GetValue(reqHeaders, "KC-API-PARTNER"), id), Helpers.add(Helpers.add("kucoin - id: ", id), " not in headers for spot orders."));
2222 try
2223 {
2224 (exchange.createOrder("BTC/USDT", "limit", "buy", 1, 20000, new java.util.HashMap<String, Object>() {{
2225 put( "uta", true );
2226 }})).join();
2227 } catch(Exception e)
2228 {
2229 reqHeaders = exchange.last_request_headers;
2230 }
2231 Assert(Helpers.isEqual(Helpers.GetValue(reqHeaders, "KC-API-PARTNER"), id), Helpers.add(Helpers.add("kucoin - id: ", id), " not in headers for spot uta orders."));
2232 id = "ccxtfutures";
2233 try
2234 {
2235 (exchange.createOrder("BTC/USDT:USDT", "limit", "buy", 1, 20000)).join();
2236 } catch(Exception e)
2237 {
2238 reqHeaders = exchange.last_request_headers;
2239 }
2240 Assert(Helpers.isEqual(Helpers.GetValue(reqHeaders, "KC-API-PARTNER"), id), Helpers.add(Helpers.add("kucoin - id: ", id), " not in headers for swap orders."));
2241 try
2242 {
2243 (exchange.createOrder("BTC/USDT:USDT", "limit", "buy", 1, 20000, new java.util.HashMap<String, Object>() {{
2244 put( "uta", true );
2245 }})).join();
2246 } catch(Exception e)
2247 {
2248 reqHeaders = exchange.last_request_headers;
2249 }
2250 Assert(Helpers.isEqual(Helpers.GetValue(reqHeaders, "KC-API-PARTNER"), id), Helpers.add(Helpers.add("kucoin - id: ", id), " not in headers for swap uta orders."));
2251 if (!Helpers.isTrue(isSync()))
2252 {
2253 (close(exchange)).join();

Callers 1

runBrokerIdTestsMethod · 0.95

Calls 10

initOfflineExchangeMethod · 0.95
addElementToObjectMethod · 0.95
GetValueMethod · 0.95
isEqualMethod · 0.95
addMethod · 0.95
createOrderMethod · 0.95
isTrueMethod · 0.95
AssertMethod · 0.80
isSyncMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected