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

Method testOkx

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

Source from the content-addressed store, hash-verified

2099 }
2100
2101 public java.util.concurrent.CompletableFuture<Object> testOkx()
2102 {
2103
2104 return java.util.concurrent.CompletableFuture.supplyAsync(() -> {
2105
2106 Exchange exchange = this.initOfflineExchange("okx");
2107 Object id = "6b9ad766b55dBCDE";
2108 Object spotOrderRequest = null;
2109 try
2110 {
2111 (exchange.createOrder("BTC/USDT", "limit", "buy", 1, 20000)).join();
2112 } catch(Exception e)
2113 {
2114 spotOrderRequest = jsonParse(exchange.last_request_body);
2115 }
2116 Object clientOrderId = Helpers.GetValue(Helpers.GetValue(spotOrderRequest, 0), "clOrdId"); // returns order inside array
2117 Object idString = String.valueOf(id);
2118 Assert(((String)clientOrderId).startsWith(((String)idString)), Helpers.add(Helpers.add(Helpers.add("okx - spot clientOrderId: ", clientOrderId), " does not start with id: "), idString));
2119 Object spotTag = Helpers.GetValue(Helpers.GetValue(spotOrderRequest, 0), "tag");
2120 Assert(Helpers.isEqual(spotTag, id), Helpers.add(Helpers.add(Helpers.add("okx - id: ", id), " different from spot tag: "), spotTag));
2121 Object swapOrderRequest = null;
2122 try
2123 {
2124 (exchange.createOrder("BTC/USDT:USDT", "limit", "buy", 1, 20000)).join();
2125 } catch(Exception e)
2126 {
2127 swapOrderRequest = jsonParse(exchange.last_request_body);
2128 }
2129 Object clientOrderIdSwap = Helpers.GetValue(Helpers.GetValue(swapOrderRequest, 0), "clOrdId");
2130 Assert(((String)clientOrderIdSwap).startsWith(((String)idString)), Helpers.add(Helpers.add(Helpers.add("okx - swap clientOrderId: ", clientOrderIdSwap), " does not start with id: "), idString));
2131 Object swapTag = Helpers.GetValue(Helpers.GetValue(swapOrderRequest, 0), "tag");
2132 Assert(Helpers.isEqual(swapTag, id), Helpers.add(Helpers.add(Helpers.add("okx - id: ", id), " different from swap tag: "), swapTag));
2133 if (!Helpers.isTrue(isSync()))
2134 {
2135 (close(exchange)).join();
2136 }
2137 return true;
2138 });
2139
2140 }
2141
2142 public java.util.concurrent.CompletableFuture<Object> testCryptocom()
2143 {

Callers 1

runBrokerIdTestsMethod · 0.95

Calls 10

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

Tested by

no test coverage detected