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).

!7

import com.bitget.openapi.dto.request.ws.SubscribeReq;

p {
  File credFile = javaxSecretDir("BitGet/trade-credentials.txt");
  
  var cred = BitGetCredentials.fromFile(credFile);
  
  var client = bitGetWSClientBuilder(cred)
    .listener(response -> {
       JSONObject json = JSONObject.parseObject(response);
       print("got: " + json);
       appendToTextFile(javaxDataDir("Crypto/btc-candles.log"), json + "\n");
     })
    .errorListener(response -> { JSONObject json = JSONObject.parseObject(response); print("error:" + json); })
    .build();
  
  print("Subscribing to BitCoin 1m candles!");
  
  client.subscribe(ll(
    SubscribeReq.builder().instType("SP").channel("candle1m").instId("BTCUSDT").build()
  ));
  
  print("Subscribed!");
}

svoid closeBitGetWebSocket(BitgetWsClient client) {
  // Trick client into closing connection without reconnect
  set(client, reconnectStatus := true);
  call(get(client, "webSocket"), "close", 1000, "Closing voluntarily");
}

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: 12 / 52
Version history: 3 change(s)
Referenced in: [show references]