Path: blob/master/bitget-java-sdk-api/src/test/java/com/bitget/openapi/ws/BitgetWsClientTest.java
518 views
package com.bitget.openapi.ws;12import com.alibaba.fastjson.JSONObject;3import com.bitget.openapi.dto.request.ws.SubscribeReq;45import java.util.ArrayList;6import java.util.List;78public class BitgetWsClientTest {910public static final String PUSH_URL = "wss://ws.bitget.com/mix/v1/stream";11public static final String API_KEY = "";12public static final String SECRET_KEY = "";13public static final String PASS_PHRASE = "";1415public static void main(String[] args) {16BitgetWsClient client = BitgetWsHandle.builder()17.pushUrl(PUSH_URL)18.apiKey(API_KEY)19.secretKey(SECRET_KEY)20.passPhrase(PASS_PHRASE)21// .signType(SignTypeEnum.RSA)22.isLogin(true)23//默认监听处理,如订阅时指定监听,默认不再接收该channel订阅信息24.listener(response -> {25JSONObject json = JSONObject.parseObject(response);26System.out.println("def:" + json);27//失败消息的逻辑处理,如:订阅失败28}).errorListener(response -> {29JSONObject json = JSONObject.parseObject(response);30System.out.println("error:" + json);31}).build();3233List<SubscribeReq> list = new ArrayList<SubscribeReq>() {{34add(SubscribeReq.builder().instType("UMCBL").channel("positions").instId("default").build());35// add(SubscribeReq.builder().instType("SP").channel("candle1W").instId("BTCUSDT").build());36}};37client.subscribe(list);38}39}404142