Retrieve Spot Account List (Implementation)
Source:R/impl_account_account_and_funding.R
get_spot_account_list_impl.Rd
Fetches a list of spot accounts from the KuCoin API asynchronously with optional filters. This internal function is designed for use within an R6 class and is not intended for direct end-user consumption, returning financial metrics in a data.table
.
Usage
get_spot_account_list_impl(
keys = get_api_keys(),
base_url = get_base_url(),
query = list(),
.__coro_env_parent__ = <environment>
)
Arguments
- keys
List containing API configuration parameters from
get_api_keys()
, including:api_key
: Character string; your KuCoin API key.api_secret
: Character string; your KuCoin API secret.api_passphrase
: Character string; your KuCoin API passphrase.key_version
: Character string; API key version (e.g.,"2"
). Defaults toget_api_keys()
.
- base_url
Character string representing the base URL for the API. Defaults to
get_base_url()
.- query
Named list of query parameters, e.g.,
list(currency = "USDT", type = "main")
. Supported:currency
(character, optional): Filter by currency (e.g.,"USDT"
).type
(character, optional): Filter by account type ("main"
,"trade"
).
Value
Promise resolving to a data.table
containing:
id
(character): Account ID.currency
(character): Currency code.type
(character): Account type (e.g.,"main"
,"trade"
).balance
(numeric): Total funds.available
(numeric): Available funds.holds
(numeric): Funds on hold.
Details
Workflow Overview
URL Construction: Combines the base URL (from
get_base_url()
or providedbase_url
) with/api/v1/accounts
and a query string frombuild_query()
.Header Preparation: Constructs authentication headers using
build_headers()
.API Request: Sends a GET request with a 3-second timeout via
httr::GET()
.Response Processing: Processes the response with
process_kucoin_response()
, converts the"data"
array into adata.table
, and handles empty responses with a typed empty table.
Examples
if (FALSE) { # \dontrun{
keys <- get_api_keys()
base_url <- "https://api.kucoin.com"
query <- list(currency = "USDT", type = "main")
main_async <- coro::async(function() {
dt <- await(get_spot_account_list_impl(keys = keys, base_url = base_url, query = query))
print(dt)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }