zj
2025-05-02 01830e44921b187b448d8cce9c9a46b9ad55af43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package project.web.api;
 
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import com.alibaba.fastjson.JSONObject;
 
import project.data.websocket.client.MarketClient;
import project.data.websocket.client.req.market.SubMarketTickerRequest;
import project.data.websocket.constant.HuobiOptions;
 
@RestController
@CrossOrigin
public class TestController {
 
    @RequestMapping("api/test")
    public void test() {
        MarketClient tickerClient = MarketClient.create(new HuobiOptions());
        String symbol = "btcusdt";
        SubMarketTickerRequest tickerReq = new SubMarketTickerRequest();
        tickerReq.setSymbol(symbol);
        tickerClient.subMarketTicker(tickerReq, (marketTradeEvent) -> {
            System.out.println(JSONObject.toJSONString(marketTradeEvent));
            // trade(marketTradeEvent, symbol);
          });
    }
}