| websocketAPIprivate | R Documentation |
Private channel of WebSocket API for Okx exchange v5 API. See Private Channel for more information.
channelPrivate WebSocket url.
api_keyOkx API key.
secret_keyOkx API secret key.
passphraseOkx API passphrase.
simulateWhether to use demo trading service.
wsA websocket::WebSocket object to establish a connection to the server.
new()Craeate a new websocketAPIprivate object.
websocketAPIprivate$new(api_key, secret_key, passphrase, simulate = FALSE)
api_keyOkx API key.
secret_keyOkx API secret key.
passphraseOkx API passphrase.
simulateWhether to use demo trading service.
get_timestamp()Get UTC timestamp.
websocketAPIprivate$get_timestamp()
get_message()Get the signing messages.
websocketAPIprivate$get_message(timestamp)
timestampRetrieve through method get_timestamp.
get_signature()Get the signature.
websocketAPIprivate$get_signature(secret_key, msg)
secret_keyOkx API secret key.
msgRetrieve through method get_message.
connect()Initiate the connection to the server.
websocketAPIprivate$connect()
login()Log in.
websocketAPIprivate$login()
on_open()Called when the connection is established.
websocketAPIprivate$on_open(func)
funcA Callback function.
on_close()Called when a previously-opened connection is closed. The event will have 'code' (integer) and 'reason' (one-element character) elements that describe the remote's reason for closing.
websocketAPIprivate$on_close(func)
funcA Callback function.
on_message()Called each time a message is received from the server. The event will have a 'data' element, which is the message content.
websocketAPIprivate$on_message(func)
funcA Callback function.
on_error()Called when the connection fails to be established. The event will have an 'message' element, a character vector of length 1 describing the reason for the error.
websocketAPIprivate$on_error(func)
funcA Callback function.
send()Send a message to the server.
websocketAPIprivate$send(msg)
msgMessages.
close()Close the connection.
websocketAPIprivate$close()
clone()The objects of this class are cloneable with this method.
websocketAPIprivate$clone(deep = FALSE)
deepWhether to make a deep clone.
## Not run:
tmp <- websocketAPIprivate$new(api_key, secret_key, passphrase)
tmp$connect()
Sys.sleep(1)
tmp$login()
# subscribe account information
msg <- list(
op = "subscribe",
args = list(
list(channel = "account", ccy = "USDT")
)
)
msg <- jsonlite::toJSON(msg, auto_unbox = TRUE, pretty = TRUE)
tmp$send(msg)
# pass your own callback function
tmp$on_message(function(event) {
if (event$data == "pong") {
cat("Bingo!!\n")
}
})
tmp$send("ping")
tmp$close()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.