Download Jar. Uses 15070K of libraries. Click here for Pure Java version (9272L/52K).
!7 // from https://github.com/BitgetLimited/v3-bitget-api-sdk/blob/master/bitget-java-sdk-api/src/test/java/com/bitget/openapi/ws/BitgetWsClientTest.java lib 1400587 // BitGet Java SDK import com.bitget.openapi.ws.*; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.bitget.openapi.dto.request.ws.SubscribeReq; import org.junit.Before; import org.junit.Test; public static final String PUSH_URL = "wss://ws.bitget.com/mix/v1/stream"; public static String API_KEY = ""; public static String SECRET_KEY = ""; public static String PASS_PHRASE = ""; p { API_KEY = args[0]; SECRET_KEY = args[1]; PASS_PHRASE = args[2]; BitgetWsClient client = BitgetWsHandle.builder() .pushUrl(PUSH_URL) .apiKey(API_KEY) .secretKey(SECRET_KEY) .passPhrase(PASS_PHRASE) .isLogin(true) //默认监听处理,如订阅时指定监听,默认不再接收该channel订阅信息 .listener(response -> { JSONObject json = JSONObject.parseObject(response); System.out.println("def:" + json); //失败消息的逻辑处理,如:订阅失败 }).errorListener(response -> { JSONObject json = JSONObject.parseObject(response); System.out.println("error:" + json); }).build(); List<SubscribeReq> list = new ArrayList<SubscribeReq>() {{ add(SubscribeReq.builder().instType("mc").channel("ticker").instId("BTCUSD").build()); add(SubscribeReq.builder().instType("SP").channel("candle1W").instId("BTCUSDT").build()); }}; client.subscribe(list); List<SubscribeReq> list2 = new ArrayList<SubscribeReq>() {{ add(SubscribeReq.builder().instType("UMCBL").channel("account").instId("default").build()); }}; client.subscribe(list2, response -> { JSONObject json = JSONObject.parseObject(response); System.out.println("appoint:" + json); }); }
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1036024 |
Snippet name: | BitGet Java SDK WebSocket Test |
Eternal ID of this version: | #1036024/8 |
Text MD5: | 125d9c68402a5b627eb82c56e9019cd1 |
Transpilation MD5: | 4a97645559ac1a2b2a44713a561d4a72 |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-09-01 14:34:40 |
Source code size: | 2290 bytes / 58 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 232 / 705 |
Version history: | 7 change(s) |
Referenced in: | -