Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1036026 // Log BTC candles :)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 15070K of libraries. Click here for Pure Java version (10115L/57K).

1  
!7
2  
3  
import com.bitget.openapi.dto.request.ws.SubscribeReq;
4  
5  
p {
6  
  File credFile = javaxSecretDir("BitGet/trade-credentials.txt");
7  
  
8  
  var cred = BitGetCredentials.fromFile(credFile);
9  
  
10  
  var client = bitGetWSClientBuilder(cred)
11  
    .listener(response -> {
12  
       JSONObject json = JSONObject.parseObject(response);
13  
       print("got: " + json);
14  
       appendToTextFile(javaxDataDir("Crypto/btc-candles.log"), json + "\n");
15  
     })
16  
    .errorListener(response -> { JSONObject json = JSONObject.parseObject(response); print("error:" + json); })
17  
    .build();
18  
  
19  
  print("Subscribing to BitCoin 1m candles!");
20  
  
21  
  client.subscribe(ll(
22  
    SubscribeReq.builder().instType("SP").channel("candle1m").instId("BTCUSDT").build()
23  
  ));
24  
  
25  
  print("Subscribed!");
26  
}
27  
28  
svoid closeBitGetWebSocket(BitgetWsClient client) {
29  
  // Trick client into closing connection without reconnect
30  
  set(client, reconnectStatus := true);
31  
  call(get(client, "webSocket"), "close", 1000, "Closing voluntarily");
32  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036026
Snippet name: Log BTC candles :)
Eternal ID of this version: #1036026/4
Text MD5: 31c5a33221497e57f3461b1e0e8ed74c
Transpilation MD5: ff116be4568bb6411b92e9cbcbcf6054
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-19 17:25:48
Source code size: 1015 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 67 / 309
Version history: 3 change(s)
Referenced in: [show references]