()
| 2003 | } |
| 2004 | |
| 2005 | public java.util.concurrent.CompletableFuture<Object> testBinance() |
| 2006 | { |
| 2007 | |
| 2008 | return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 2009 | |
| 2010 | Exchange exchange = this.initOfflineExchange("binance"); |
| 2011 | Object spotId = "x-TKT5PX2F"; |
| 2012 | Object swapId = "x-cvBPrNm9"; |
| 2013 | Object inverseSwapId = "x-xcKtGhcu"; |
| 2014 | Object spotOrderRequest = null; |
| 2015 | try |
| 2016 | { |
| 2017 | (exchange.createOrder("BTC/USDT", "limit", "buy", 1, 20000)).join(); |
| 2018 | } catch(Exception e) |
| 2019 | { |
| 2020 | spotOrderRequest = this.urlencodedToDict(exchange.last_request_body); |
| 2021 | } |
| 2022 | Object clientOrderId = Helpers.GetValue(spotOrderRequest, "newClientOrderId"); |
| 2023 | Object spotIdString = String.valueOf(spotId); |
| 2024 | Assert(((String)clientOrderId).startsWith(((String)spotIdString)), Helpers.add(Helpers.add(Helpers.add("binance - spot clientOrderId: ", clientOrderId), " does not start with spotId"), spotIdString)); |
| 2025 | Object swapOrderRequest = null; |
| 2026 | try |
| 2027 | { |
| 2028 | (exchange.createOrder("BTC/USDT:USDT", "limit", "buy", 1, 20000)).join(); |
| 2029 | } catch(Exception e) |
| 2030 | { |
| 2031 | swapOrderRequest = this.urlencodedToDict(exchange.last_request_body); |
| 2032 | } |
| 2033 | Object swapInverseOrderRequest = null; |
| 2034 | try |
| 2035 | { |
| 2036 | (exchange.createOrder("BTC/USD:BTC", "limit", "buy", 1, 20000)).join(); |
| 2037 | } catch(Exception e) |
| 2038 | { |
| 2039 | swapInverseOrderRequest = this.urlencodedToDict(exchange.last_request_body); |
| 2040 | } |
| 2041 | // linear swap |
| 2042 | Object clientOrderIdSwap = Helpers.GetValue(swapOrderRequest, "newClientOrderId"); |
| 2043 | Object swapIdString = String.valueOf(swapId); |
| 2044 | Assert(((String)clientOrderIdSwap).startsWith(((String)swapIdString)), Helpers.add(Helpers.add(Helpers.add("binance - swap clientOrderId: ", clientOrderIdSwap), " does not start with swapId"), swapIdString)); |
| 2045 | // inverse swap |
| 2046 | Object clientOrderIdInverse = Helpers.GetValue(swapInverseOrderRequest, "newClientOrderId"); |
| 2047 | Assert(((String)clientOrderIdInverse).startsWith(((String)inverseSwapId)), Helpers.add(Helpers.add(Helpers.add("binance - swap clientOrderIdInverse: ", clientOrderIdInverse), " does not start with swapId"), inverseSwapId)); |
| 2048 | // linear swap conditional order |
| 2049 | Object swapAlgoOrderRequest = null; |
| 2050 | try |
| 2051 | { |
| 2052 | (exchange.createOrder("BTC/USDT:USDT", "limit", "buy", 0.002, 102000, new java.util.HashMap<String, Object>() {{ |
| 2053 | put( "triggerPrice", 101000 ); |
| 2054 | }})).join(); |
| 2055 | Object checkOrderRequest = this.urlencodedToDict(exchange.last_request_body); |
| 2056 | Object algoOrderIdDefined = (!Helpers.isEqual(Helpers.GetValue(checkOrderRequest, "algoOrderId"), null)); |
| 2057 | Assert(algoOrderIdDefined, "binance - swap clientOrderId needs to be sent as algoOrderId but algoOrderId is not defined"); |
| 2058 | Object clientAlgoIdSwap = Helpers.GetValue(swapAlgoOrderRequest, "clientAlgoId"); |
| 2059 | Object swapAlgoIdString = String.valueOf(swapId); |
| 2060 | Assert(((String)clientAlgoIdSwap).startsWith(((String)swapAlgoIdString)), Helpers.add(Helpers.add(Helpers.add("binance - swap clientOrderId: ", clientAlgoIdSwap), " does not start with swapId"), swapAlgoIdString)); |
| 2061 | } catch(Exception e) |
| 2062 | { |
no test coverage detected