| restAPI | R Documentation |
Base class for Okx exchange v5 API.
You can implement all REST API requests in Okx exchange by inheriting the restAPI class.
Please refer to the example provided at the end of the document.
For commonly used interfaces, they have been implemented in this package.
The naming convention is as follows: for "/api/v5/AAA/BBB", a new class named restAPIAAA,
which inherits from restAPI, has been defined in this package.
The BBB method in this new class is used to call the API.
urlOkx REST API url, which is https://www.okx.com.
api_keyOkx API key.
secret_keyOkx API secret key.
passphraseOkx API passphrase.
simulateWhether to use demo trading service.
new()Create a new REST API object.
restAPI$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.
restAPI$get_timestamp()
get_request_path()Get request path.
restAPI$get_request_path(api, method = c("GET", "POST"), ...)apiRequest api e.g. /api/v5/account/positions-history.
methodRequest method, GET or POST.
...Other request parameters.
get_body()Get request body.
restAPI$get_body(method = c("GET", "POST"), ...)methodRequest method, GET or POST.
...Other request parameters.
get_message()Get the signing messages.
restAPI$get_message(timestamp, request_path, body, method = c("GET", "POST"))timestampRetrieve through method get_timestamp.
request_pathRetrieve through method get_request_path.
bodyRetrieve through method get_body.
methodRequest method, GET or POST.
get_signature()Get the signature.
restAPI$get_signature(msg, secret_key = self$secret_key)
msgRetrieve through method get_message.
secret_keyOkx API secret key.
get_header()Get request headers.
restAPI$get_header(timestamp, msg)
timestampRetrieve through method get_timestamp.
msgRetrieve through method get_message.
get_result()Retrieve data from api.
restAPI$get_result(api, method = c("GET", "POST"), process, ...)apiRequest api e.g. /api/v5/account/positions-history.
methodRequest method, GET or POST.
processA function to process the data received from the API.
...Other request parameters.
clone()The objects of this class are cloneable with this method.
restAPI$clone(deep = FALSE)
deepWhether to make a deep clone.
restAPItrade
restAPIaccount
restAPImarket
## Not run:
# for [Get currencies](https://www.okx.com/docs-v5/en/#rest-api-funding-get-currencies)
# you can define the class like this
myRestAPI <- R6::R6Class(
inherit = restAPI,
public = list(
get_currencies = function(ccy, process = "identity") {
self$get_result(
api = "/api/v5/asset/currencies", method = "GET", process = process,
ccy = ccy
)
}
)
)
# And call it like this
tmp <- myRestAPI$new(api_key, secret_key, passphrase)
tmp$get_currencies("BTC")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.