sclass BitGet { S domain = "https://api.bitget.com"; S webSocketURL = "wss://ws.bitget.com/spot/v1/stream"; Timestamp serverTime() { ret new Timestamp(toLong(loadJSONMapPage(domain + "/api/spot/v1/public/time").get("data"))); } // How much we are ahead or behind of the server's time // (Note: includes network lag) Duration serverTimeDifference() { var serverTime = serverTime(); ret tsNow().minusAsDuration(serverTime); } WebSocketClient printingWebSocketClient() ctex { ret new PrintingWebSocketClient(new URI(webSocketURL)); } S signMessage(S message, BitGetCredentials cred) { ret base64(hmacSHA256(message, hexToBytes(assertNempty(cred.secretKey())))); } Map loginRequest(BitGetCredentials cred) { S timestamp = str(serverTime().unixSeconds()); S messageToSign = timestamp /* + "GET" + "/user/verify"*/; S sign = signMessage(messageToSign, cred); ret litorderedmap( op := "login", args := ll(litorderedmap( apiKey := assertNempty(cred.apiKey), passphrase := assertNempty(cred.passphrase), +timestamp, +sign ))); } }